環(huán)境:centos6.5
生產(chǎn)環(huán)境最好源碼編譯安裝Apache,可靈活定制各種功能、及時(shí)獲取軟件的最新版本以及便于今后在不同的系統(tǒng)之間移植。
yum安裝apache
1、檢查是否安裝apache
[root@h1 ~]# rpm -qa | grep httpd
httpd-tools-2.2.15-29.el6.centos.x86_64
httpd-2.2.15-29.el6.centos.x86_64
2、卸載自帶默認(rèn)apache,并再次檢查
[root@h1 ~]# rpm -e --nodeps httpd-tools-2.2.15-29.el6.centos.x86_64
[root@h1 ~]# rpm -e --nodeps httpd-2.2.15-29.el6.centos.x86_64
[root@h1 ~]# rpm -qa | grep httpd
[root@h1 ~]#
或者yum卸載
[root@h1 ~]# yum remove httpd* -y
3、yum安裝
[root@h1 ~]# yum install httpd -y
[root@h1 ~]# rpm -qa | grep httpd
httpd-tools-2.2.15-60.el6.centos.6.x86_64
httpd-2.2.15-60.el6.centos.6.x86_64
4、啟動(dòng)apache服務(wù)
[root@h1 ~]# /etc/init.d/httpd start
正在啟動(dòng) httpd:httpd: apr_sockaddr_info_get() failed for h1
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
這個(gè)報(bào)錯(cuò)需要更改配置文件
[root@h1 init.d]# vi /etc/httpd/conf/httpd.conf
取消276行servername注釋即可
#
ServerName www.example.com:80
這個(gè)報(bào)錯(cuò)說明80端口一直被占用,
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[失敗]
找到占用80端口的進(jìn)程
[root@h1 init.d]# netstat -lnp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9855/nginx
tcp 0 0 :::54980 :::* LISTEN 1591/rpc.statd
unix 2 [ ACC ] STREAM LISTENING 19380 2397/evolution-alar /tmp/orbit-root/linc-95d-0-35b0575818c16
是因?yàn)橐郧皽y(cè)試nginx占用了80端口,殺掉占用80端口的pid進(jìn)程,或者更改默認(rèn)端口
[root@h1 init.d]# kill 9855
[root@h1 init.d]# netstat -lnp|grep 80
tcp 0 0 :::54980 :::* LISTEN 1591/rpc.statd
unix 2 [ ACC ] STREAM LISTENING 19380 2397/evolution-alar /tmp/orbit-root/linc-95d-0-35b0575818c16
[root@h1 init.d]#
重啟成功
[root@h1 init.d]# /etc/init.d/httpd restart
停止 httpd: [確定]
正在啟動(dòng) httpd: [確定]
直接訪問即可