Apache fails启动,已经运行,但没有machid pid文件?

每当我尝试启动/重新启动我的apache2服务使用systemctl我得到一个关于它已经运行的错误,但没有加工我的pid file

 ● apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: failed (Result: exit-code) since Mon 2017-01-09 21:42:38 EST; 16s ago Docs: man:systemd-sysv-generator(8) Process: 18354 ExecStop=/etc/init.d/apache2 stop (code=exited, status=1/FAILURE) Process: 18337 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS) Jan 09 21:42:38 username apache2[18337]: Action 'start' failed. Jan 09 21:42:38 username apache2[18337]: The Apache error log may have more information. Jan 09 21:42:38 username apache2[18337]: * Jan 09 21:42:38 username apache2[18354]: * Stopping Apache httpd web server apache2 Jan 09 21:42:38 username apache2[18354]: * Jan 09 21:42:38 username apache2[18354]: * There are processes named 'apache2' running which do not match your pid file which are left untouched in the name of safety, Please review the situation by hand. Jan 09 21:42:38 username systemd[1]: apache2.service: Control process exited, code=exited status=1 Jan 09 21:42:38 username systemd[1]: Failed to start LSB: Apache2 web server. Jan 09 21:42:38 username systemd[1]: apache2.service: Unit entered failed state. Jan 09 21:42:38 username systemd[1]: apache2.service: Failed with result 'exit-code'. 

运行ps aux | grep apache2 ps aux | grep apache2显示有东西已经在运行,但我不能杀死它们。 只要我杀了他们,他们在不同的PID下重新产卵。

 root 8931 0.0 0.2 227232 23632 ? Ss 21:30 0:00 apache2 -DFOREGROUND username 9193 0.0 0.1 227264 9056 ? S 21:30 0:00 apache2 -DFOREGROUND username 9194 0.0 0.1 227264 9056 ? S 21:30 0:00 apache2 -DFOREGROUND username 9195 0.0 0.1 227264 9056 ? S 21:30 0:00 apache2 -DFOREGROUND username 9196 0.0 0.1 227264 9056 ? S 21:30 0:00 apache2 -DFOREGROUND username 9197 0.0 0.1 227264 9056 ? S 21:30 0:00 apache2 -DFOREGROUND 

/var/log/apache2/errors.log下的apache日志是空的。

使用sudo strace -p 8931附加到第一个pid,我得到:

 strace: Process 8931 attached select(0, NULL, NULL, NULL, {0, 58750}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}) = 0 (Timeout) wait4(-1, 0x7ffc2296e9bc, WNOHANG|WSTOPPED, NULL) = 0 select(0, NULL, NULL, NULL, {1, 0}^Cstrace: Process 8931 detached 

一遍又一遍地重复

运行sudo /usr/sbin/apachectl -k start会出现以下错误。 我不知道是什么使用80端口。

 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down AH00015: Unable to open logs Action '-k start' failed. The Apache error log may have more information. 

在运行sudo netstat -lnpt我发现我忘记了我正在运行的docker集装箱…

 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name ... tcp6 0 0 :::80 :::* LISTEN 8856/docker-proxy ... 

活跃:失败(结果:退出代码)自一月2017-01-09 21:42:38 EST; 16s前

这意味着服务没有正常启动,尝试使用“#/ apacheHome / bin / apachectl -k start / stop”手动启动并检入日志。

 sudo netstat -tulpn | grep :80 

你会得到类似的输出

 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1066/lighttpd 

注意侦听端口的进程的PID,在我的情况下是1066.然后运行

 sudo kill -9 1066 

请记住,要改变正在监听端口的pid,它可能与1066不一样

这对我有效。