CentOS6上Apache伺服器的安裝與配置
阿新 • • 發佈:2019-01-27
一、安裝Apache程式,一般有三種安裝方式:
1.直接yum安裝;
yum -y install httpd
2.下載rpm包,上傳至伺服器進行安裝;
rpm -qa | grep httpd
3.通過原始碼編譯安裝;
啟動/停止/重新啟動/狀態
service httpd start
service httpd stop
service httpd restart
service httpd status
pstree | grep httpd //驗證服務是否啟動,比較少用;
啟動時,如果提示如下資訊:
正在啟動 httpd:httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain for ServerName
編輯/etc/httpd/conf/httpd.conf
找到如下內容:
ServerName www.example.com:80
更改為
ServerName localhost:80
再重啟一下Apache服務即可;
測試安裝配置是否成功 >> http://ip地址
如果打不開,那應該是iptables的問題;
編輯/etc/sysconfig/iptables
新增如下內容:
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 443 -j ACCEPT
然後重啟一下iptables服務可;