- 论坛徽章:
- 0
|
本帖最后由 ogusu 于 2013-12-03 14:01 编辑
1. 首先Apapche的包的相关文件的版本和显示Apache的版本不一致,是怎么回事?
[root@xxxx ~]# /usr/local/apache2/bin/httpd -v
Server version: Apache/2.2.3
Server built: Apr 23 2013 00:06:47
[root@xxxx ~]# yum list | grep httpd
httpd.i686 2.2.15-29.el6.centos @updates
httpd-tools.i686 2.2.15-29.el6.centos @updates
httpd-devel.i686 2.2.15-29.el6.centos updates
httpd-manual.noarch 2.2.15-29.el6.centos updates
[root@xxxx ~]# rpm -qa | grep httpd
httpd-2.2.15-29.el6.centos.i686
httpd-tools-2.2.15-29.el6.centos.i686
2. 关于启动方式
我现在的机器上有两个comannd可以自行Apache的启动,不知道他们之间有什么联系,Apache只有一个,为什么这两个启动会各管各的呢。
[root@xxxx ~]# /etc/rc.d/init.d/httpd [start/restart/stop]
[root@xxxx ~]# /usr/local/apache2/bin/apachectl [start/restart/stop]
下面把现象说一下。
【现象一】
[root@xxxx ~]# /etc/rc.d/init.d/httpd status
httpd not running ---显示Apache已经停止了
[root@xxxx ~]# /usr/local/apache2/bin/apachectl start
httpd (pid 11612) already running ---却显示Apache已经启动
并且在这种情况下,无论是在linux服务器上还是在windows的客户端上都都可以显示Apache默认目录下的网页,“It works!”
【现象二】
是关于phpinfo.php页面的显示。
[root@xxxx ~]# /etc/rc.d/init.d/httpd status
httpd not running ---显示Apache已经停止了
[root@xxxx ~]# /usr/local/apache2/bin/apachectl start ---Apache启动成功
打开phpinfo.php页面无法辨析,提示下载问题。
※从这里开始附上Evidence
[root@xxxx ~]# /etc/rc.d/init.d/httpd start ,出现地址被使用的错误
关闭提示里所有的相关进程
[root@xxxx ~]# /etc/rc.d/init.d/httpd start ,成功
再次打开phpinfo.php页面,一片空白
修改php.ini文件后,重新启动Apache
[root@xxxx ~]# /etc/rc.d/init.d/httpd restart ---重启成功
再次打开phpinfo.php页面,还是一片空白
重启Apache
[root@xxxx ~]# /usr/local/apache2/bin/apachectl restart ,再次出现地址被使用的错误
关闭提示里所有的相关进程,再重启
[root@xxxx ~]# /usr/local/apache2/bin/apachectl restart ---重启成功
再次打开phpinfo.php页面,成功。
这里还有一个问题就是为什么已经kill掉的进程,又再次出现。重启Apache,都要kill一下相关的进程,是不是应该在哪里设置一下?
启动Apache时,到底是启动哪一个?为什么会出现我碰到的现象呢?
下面附上现象二的一连串的Evidence,以供参考
用 [root@xxxx ~]# /etc/rc.d/init.d/httpd start 来启动的话,出现错误
[root@s-nxm05ap-v11 ~]# /etc/rc.d/init.d/httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(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
查看相关port及其进程
[root@xxxx ~]# /usr/sbin/lsof -i | grep http
clock-app 6248 test 21u IPv4 241187 0t0 TCP 192.168.2.231:59489->203.179.83.12:http (CLOSE_WAIT)
httpd 11612 root 4u IPv6 62253 0t0 TCP *:http (LISTEN)
httpd 27684 daemon 4u IPv6 62253 0t0 TCP *:http (LISTEN)
httpd 27685 daemon 4u IPv6 62253 0t0 TCP *:http (LISTEN)
httpd 27686 daemon 4u IPv6 62253 0t0 TCP *:http (LISTEN)
httpd 27687 daemon 4u IPv6 62253 0t0 TCP *:http (LISTEN)
httpd 27688 daemon 4u IPv6 62253 0t0 TCP *:http (LISTEN)
[root@xxxx ~]# netstat -lnp | grep 80
tcp 0 0 :::80 :::* LISTEN 11612/httpd
unix 2 [ ACC ] STREAM LISTENING 50725 6149/bluetooth-appl /tmp/orbit-test/linc-1805-0-9cb3721b002e
unix 2 [ ACC ] STREAM LISTENING 50662 6156/gpk-update-ico /tmp/orbit-test/linc-180c-0-447592d649630
于是把那些port为80的进程kill掉。
[root@xxxx ~]# kill -9 11612
[root@xxxx ~]# kill -9 27684
...
[root@xxxx ~]# kill -9 27688
再来确认还有那些port为80的进程
[root@xxxx ~]# netstat -lnp | grep 80
unix 2 [ ACC ] STREAM LISTENING 50725 6149/bluetooth-appl /tmp/orbit-test/linc-1805-0-9cb3721b002e
unix 2 [ ACC ] STREAM LISTENING 50662 6156/gpk-update-ico /tmp/orbit-test/linc-180c-0-447592d649630
显示没有多余的port为80的进程,重新启动apache
[root@xxxx ~]# /etc/rc.d/init.d/httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
再次打开phpinfo.php,显示一片空白。
于是修改了php.ini里的short_open_tag = On
重新启动Apache
[root@xxxx ~]# /etc/rc.d/init.d/httpd restart ---成功
再次打开phpinfo.php,还是显示一片空白。
重新[root@xxxx ~]# /usr/local/apache2/bin/apachectl restart
这回又出现了错误
httpd not running, trying to start
(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
再次调查port为80的进程
[root@xxxx ~]# /usr/sbin/lsof -i | grep http
clock-app 6248 test 21u IPv4 245306 0t0 TCP 192.168.2.231:59522->203.179.83.12:http (CLOSE_WAIT)
httpd 27836 root 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27839 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27840 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27841 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27842 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27843 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27844 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27845 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
httpd 27846 apache 4u IPv6 246159 0t0 TCP *:http (LISTEN)
然后再一次次全部把多余的进程kill掉
[root@xxxx ~]# kill -9 27836
[root@xxxx ~]# kill -9 27839
...
[root@xxxx ~]# kill -9 27846
再启动Apache
[root@xxxx ~]# /usr/local/apache2/bin/apachectl restart
然后再一次在客户端打开phpinfo.php,显示成功
php网页显示成功后,再调查一下port以及相关进程
[root@xxxx ~]# /usr/sbin/lsof -i | grep http
clock-app 6248 test 21u IPv4 246789 0t0 TCP 192.168.2.231:59555->203.179.83.12:http (CLOSE_WAIT)
httpd 27865 root 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27866 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27867 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27868 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27869 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27870 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27871 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27872 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
httpd 27873 daemon 4u IPv6 246708 0t0 TCP *:http (LISTEN)
那不是说等下次再重启Apache时候,又需要kill一些进程吗?
|
|