1. 程式人生 > >centos7 apache 安裝配置步驟

centos7 apache 安裝配置步驟

1 檢查、刪除、安裝

rpm -qa|grep httpd    //檢查是否安裝apache
rpm -e 包名 --nodeps    //若有則刪除  PS:我沒有刪除,直接用的伺服器原來的。
yum install httpd     //安裝,根據提示,輸入Y即可安裝成功

2 啟動、測試

systemctl start httpd //restart 重啟 stop停止

3 檢視 apache狀態

service httpd status

配置httpd.conf檔案,把AllowOverride改為了All。

vi /etc/httpd/conf/httpd.conf

檢視已經開放的埠:

firewall-cmd --list-ports

如果沒有80埠

開啟埠

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含義:

–zone #作用域

–add-port=80/tcp #新增埠,格式為:埠/通訊協議

–permanent #永久生效,沒有此引數重啟後失效

重啟防火牆

firewall-cmd --reload #重啟firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
firewall-cmd --state #檢視預設防火牆狀態(關閉後顯示notrunning,開啟後顯示running)

訪問ip


資料:https://www.linuxidc.com/Linux/2016-12/138979.htm