Amazon EC2-Apache服务器重启问题 [英] Amazon EC2 - Apache server restart issue
问题描述
当我运行此命令时
sudo/etc/init.d/httpd重新启动
sudo /etc/init.d/httpd restart
它给出以下错误
停止httpd:[失败]
Stopping httpd: [FAILED]
开始httpd:(98)已经使用的地址:make_sock:无法绑定到地址[::]:80 (98)地址已在使用中:make_sock:无法绑定到地址0.0.0.0:80 没有可用的侦听套接字,正在关闭 无法打开日志[失败]
Starting httpd: (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 [FAILED]
我使用
netstat -lnp | grep:80(给出下面的输出)
netstat -lnp | grep :80 (it gives below output)
tcp 0 0 ::: 80 ::: * LISTEN 21739/httpd
tcp 0 0 :::80 :::* LISTEN 21739/httpd
为什么我无法使用sudo/etc/init.d/httpd restart来停止停止apache?
why i am not able to stop stop apache by using sudo /etc/init.d/httpd restart?
下面的命令可以正常工作
below commands work without issue
sudo apachectl停止
sudo apachectl stop
sudo apachectl开始
sudo apachectl start
我正在使用Amazon EC2的Linux微型实例
i am using linux micro instance of amazon ec2
推荐答案
当我从源代码安装apache时遇到了这个问题,但随后尝试运行
I ran into this problem when I installed apache from source, but then tried to run
$ sudo /etc/init.d/httpd restart
使用的是预先安装的apache版本. /etc/init.d/httpd中的stop指令未删除启动apache的源安装版本时创建的httpd.pid文件.
which was using a pre-installed version of apache. The stop directive in /etc/init.d/httpd was not removing the httpd.pid file that was created when starting the source-installed version of apache.
要确定这也是您遇到问题的原因,请查找运行时设置httpd.pid文件的位置
To determine if this is also the reason for your problem, find where the httpd.pid file is getting set when you run
$ sudo apachectl start
如果从源代码安装并且apache2位于/usr/local/apache2中,则应该在/usr/local/apache2/logs中创建httpd.pid文件.当您通过运行停止apache
If you installed from source and apache2 is living in /usr/local/apache2, then the httpd.pid file should get created in /usr/local/apache2/logs. When you stop apache by running
$ sudo apachectl stop
该文件应被删除.因此,要测试httpd.pid文件是否引起了您的问题,请通过调用
this file should get removed. So to test if the httpd.pid file is causing your problem, start apache by calling
$ sudo apachectl start
并找到httpd.pid文件.然后尝试通过使用
and locate the httpd.pid file. Then try stopping apache by using
$ sudo /etc/init.d/httpd stop
如果原始的httpd.pid文件仍然存在,那么这就是为什么当您使用app时无法启动
If the original httpd.pid file is still present, then that is why apache is unable to start when you use
$ sudo /etc/init.d/httpd start
要使我的/etc/init.d/httpd文件正常工作,我将调用apachectl明确地放在了start和stop方法中:
To get my /etc/init.d/httpd file to work correctly, I explicitly put the call to apachectl in the start and stop methods:
#!/bin/bash
# /etc/init.d/httpd
#
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
pid=/usr/local/apache2/logs/httpd.pid
prog=httpd
RETVAL=0
start() {
echo -n $"Starting $prog: "
$apachectl -k start
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
$apachectl -k stop
RETVAL=$?
echo
}
这篇关于Amazon EC2-Apache服务器重启问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!