部署apache
部署apache
使用yum安装
yum install -y httpd
配置防火墙
centos7默认防火墙firewall,配置防火墙开放80端口。
#配置80端口开放
firewall-cmd --zone=public --add-port=80/tcp --permanent
#跟新规则
firewall-cmd --reload
#查看
firewall-cmd --query-port=80/tcp
出现Unit firewalld.service could not be found.情况,运行以下命令安装firewalld模块即可
yum install firewalld systemd -y
centos7防火墙服务
#开启
systemctl start firewalld.service
#重启
systemctl restart firewalld.service
#查看
systemctl status firewalld.service
#关闭
systemctl stop firewalld.service
#禁用(开机禁用)
systemctl disable firewalld.service
#启用(开机开启)
systemctl enable firewalld.service
关闭SELinux
SELinux是Linux的一个安全子系统,如果你不熟悉Linux的,干脆把它关了就行了。
临时关闭
setenforce 0
配置更改
主配置文件位于:/etc/httpd/conf/httpd.conf
yum安装的话配置文件一般不用改,注意几个点即可
#看看你有没有监听80端口
Listen 80
#这个可以选择改(默认就是开放的),这个为对所有ip都允许访问/var/www/html
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride All
Allow from all
Require all granted
</Directory>
启动
systemctl start httpd
整合PHP
一样使用yum下载
sudo yum install -y php
然后重启apache服务器即可,使用yum安装的php好像会处理apache之间的整合,所以这里不用修改也能用。
systemctl start httpd
测试
在/var/www/html目录下弄一个index.php,然后访问一下试试即可。
vim /var/www/html/index.php
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)