免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 7959 | 回复: 18
打印 上一主题 下一主题

[系统安装] 【请教】关于Apache的启动问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-12-03 14:02 |只看该作者 |倒序浏览
本帖最后由 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一些进程吗?

论坛徽章:
0
2 [报告]
发表于 2013-12-03 15:07 |只看该作者
本帖最后由 ogusu 于 2013-12-03 15:21 编辑

apachectl 是Apache启动的实体程序吧?

我查了一下,发现有2个apachectl 存在
/usr/sbin/apachectl
/usr/local/apache2/bin/apachectl


为什么会这样呢?应该如何统一起来呢?

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
3 [报告]
发表于 2013-12-03 15:45 |只看该作者
用rpm命令把2.2.15那个卸载掉

论坛徽章:
0
4 [报告]
发表于 2013-12-03 16:20 |只看该作者
回复 3# Shell_HAT


不行,删不掉。因为php-5.3.3已经安装了

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
5 [报告]
发表于 2013-12-03 16:22 |只看该作者
回复 4# ogusu


    没有什么是删不掉的,是你不想删吧。php有啥关系

论坛徽章:
0
6 [报告]
发表于 2013-12-03 16:44 |只看该作者
回复 5# Shell_HAT
???为什么我不想删呢

我删除时,出现错误了,Processing Dependency: httpd-mmn = 20051115 for package: php-5.3.3-23.el6_4.i686

是不是还要把php给删掉?再来删除这多余的apahce?

另外,Apache是不能多个版本共存的吗?

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
7 [报告]
发表于 2013-12-03 16:46 |只看该作者
楼主参考的资料太乱了.

同一时刻, 最好只看一份资料, 这样, 你才可能做出结果. 如果看得太多了, 你反倒不知道哪个是对的了.

论坛徽章:
0
8 [报告]
发表于 2013-12-03 16:53 |只看该作者
回复 7# q1208c


我也想只看一份啊。这不,原来是安装好了的机子,我拿来学习的。我现在是那个晕啊,就算是多重apache启动吧,每次这个启动完了,那个又出来端口问题,全部kill后,启动完毕了,再启动另一个又来端口问题了。我都快疯了。

怎么别人就没碰到这样的问题呢

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
9 [报告]
发表于 2013-12-03 16:57 |只看该作者
回复 8# ogusu

同时启动两个以上的apache, 需要监听不同的端口, 否则会报端口被占用的.

其实, 一般也没必要用两个apache. 有一个足够了.

我建议你用OS自带的, 就是 yum能看到的那个.  这样可以有官方文档可以参考.


   

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
10 [报告]
发表于 2013-12-03 16:59 |只看该作者
回复 6# ogusu


    删吧,趁机会多熟悉一下。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP