为什么我无法在 Ubuntu 上重新加载 apache2?

问题描述:

在 Ubuntu 上,每次我使用 sudo service apache2 reload 命令重新加载 apache2 服务时,我的终端都显示

On Ubuntu, each time I use sudo service apache2 reload command to reload apache2 service , my terminal showed

apache2.service is not active, cannot reload.     

而且,我正在尝试将 phpMyAdmin 添加为虚拟主机,使用 phpmyadmin.local 作为局域网域名;谁能告诉我怎么做?今天试了很多次,找了很多方法,但是到现在还是404 not found.

And, I'm trying to add phpMyAdmin as virtual host, using phpmyadmin.local as local-area-network domain name; can anyone tell me how? I have tried many times today, I searched many methods, but until now, it's still 404 not found.

我在 Ubuntu 16.04 上遇到了同样的问题.这导致 logrotate 出现问题,因为它无法在轮换日志后重新加载 Apache.

I had the same problem with Ubuntu 16.04. This was causing problems with logrotate, because it could not reload Apache after rotating logs.

我得到的完整错误:

/etc/init.d/apache2 reload
[....] Reloading apache2 configuration (via systemctl):    apache2.serviceapache2.service is not active, cannot reload.
 failed!

使用 apachectl 停止 Apache 并使用/etc/init.d/apache2 启动后问题就消失了:

The problem went away after stopping Apache with apachectl and starting it with /etc/init.d/apache2:

apachectl stop
/etc/init.d/apache2 start

您现在可以重新加载 Apache:

You can now reload Apache:

/etc/init.d/apache2 reload
[ ok ] Reloading apache2 configuration (via systemctl): apache2.service.

如果您使用 apachectl start 启动 Apache,它不会被标记为活动服务,因此您无法使用 service apache2 reload 重新加载它.您必须使用 /etc/init.d/apache2 startservice apache2 start 启动 Apache.

If you start Apache with apachectl start, it is not being marked as an active service, so you can't reload it with service apache2 reload. You have to start Apache with /etc/init.d/apache2 start or service apache2 start.

我不确定这是故意的还是错误.我无法用旧系统重现这个.

I'm not sure if it's intended or a bug. I can't reproduce this with an older system.