Ubuntu

如何在 ubuntu 上停止 apache2 - 沒有程序可見

  • January 19, 2017

我剛剛安裝了 ubuntu 16.04 和 apache2。即使我停止 apache2,也會顯示預設配置頁面。這很奇怪,因為沒有程序 httpd。伺服器繼續提供預設文件並更改文件顯示更改。

這是控制台上的輸出:

user@rex:~$ sudo /etc/init.d/apache2 stop
[ ok ] Stopping apache2 (via systemctl): apache2.service.
user@rex:~$ ps -ef | grep httpd
user      1855  1642  0 16:03 pts/0    00:00:00 grep --color=auto httpd
user@rex:~$ sudo /etc/init.d/apache2 status
● 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: inactive (dead) since Thu 2017-01-19 16:03:20 CET; 44s ago
    Docs: man:systemd-sysv-generator(8)
 Process: 1785 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
 Process: 1768 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)

Jan 19 16:03:20 rex apache2[1768]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Jan 19 16:03:20 rex apache2[1768]: no listening sockets available, shutting down
Jan 19 16:03:20 rex apache2[1768]: AH00015: Unable to open logs
Jan 19 16:03:20 rex apache2[1768]: Action 'start' failed.
Jan 19 16:03:20 rex apache2[1768]: The Apache error log may have more information.
Jan 19 16:03:20 rex apache2[1768]:  *
Jan 19 16:03:20 rex apache2[1785]:  * Stopping Apache httpd web server apache2
Jan 19 16:03:20 rex apache2[1785]:  *
Jan 19 16:03:20 rex systemd[1]: Started LSB: Apache2 web server.
Jan 19 16:03:46 rex systemd[1]: Stopped LSB: Apache2 web server.

這裡可能是什麼問題?

首先,Ubuntu 上的 apache 程序命名apache2httpdCentOS 不同。因此,您需要驗證它是否已停止使用:

$ ps -ef | grep apache

此外,您需要使用以下命令確認沒有程序正在偵聽埠 80:

$ sudo netstat -lntp | grep 80

另一件要確認的事情,查看 apache2 訪問日誌以確認您正在訪問這台機器而不是其他任何機器/var/log/apache2/access.log

引用自:https://serverfault.com/questions/827317