我尝试启用两个虚拟主机:
root@Debian-86-jessie-64-LAMP - # a2ensite chimney_es.conf
Enabling site chimney_es.
To activate the new configuration, you need to run:
service apache2 reload
root@Debian-86-jessie-64-LAMP - # a2ensite chimney_be.conf
Enabling site chimney_be.
To activate the new configuration, you need to run:
service apache2 reload
然后我做了service apache2 graceful
:
root@Debian-86-jessie-64-LAMP - # service apache2 graceful
[ ok ] Reloading web server: apache2.
对我来说似乎还可以。但是很显然,之后apache2不再运行了:
root@Debian-86-jessie-64-LAMP - # service apache2 status
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2)
Drop-In: /lib/systemd/system/apache2.service.d
└─forking.conf
Active: inactive (dead) since Thu 2018-06-21 16:15:11 CEST; 1min 33s ago
Process: 25896 ExecStop=/etc/init.d/apache2 stop (code=exited,
status=0/SUCCESS)
Process: 8760 ExecReload=/etc/init.d/apache2 reload (code=exited,
status=0/SUCCESS)
Process: 4764 ExecStart=/etc/init.d/apache2 start (code=exited,
status=0/SUCCESS)
Jun 19 06:25:07 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 19 06:25:07 Debian-86-jessie-64-LAMP apache2[22141]: Reloading web
server: apache2.
Jun 19 06:25:07 Debian-86-jessie-64-LAMP systemd[1]: Reloaded LSB: Apache2
web server.
Jun 20 06:25:07 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 20 06:25:07 Debian-86-jessie-64-LAMP apache2[6548]: Reloading web server:
apache2.
Jun 20 06:25:07 Debian-86-jessie-64-LAMP systemd[1]: Reloaded LSB: Apache2
web server.
Jun 21 06:25:07 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 21 06:25:07 Debian-86-jessie-64-LAMP apache2[8760]: Reloading web server:
apache2.
Jun 21 06:25:07 Debian-86-jessie-64-LAMP systemd[1]: Reloaded LSB: Apache2
web server.
Jun 21 16:15:11 Debian-86-jessie-64-LAMP apache2[25896]: Stopping web server:
apache2.
这引出了我的第一个问题:我了解我在.conf文件中犯了一个错误,但是我认为service apache2 graceful
的整个概念就是要捕获此类错误,我至少会预期出现错误消息。还是我在这里误会了?
无论如何,我要做的第一件事是再次禁用站点并再次启动apache,也没有引发任何错误:
root@Debian-86-jessie-64-LAMP - # a2dissite chimney_be.conf
Site chimney_be disabled.
To activate the new configuration, you need to run:
service apache2 reload
root@Debian-86-jessie-64-LAMP - # a2dissite chimney_es.conf
Site chimney_es disabled.
To activate the new configuration, you need to run:
service apache2 reload
root@Debian-86-jessie-64-LAMP ~ # service apache2 start
一直工作到我再次进行重新加载时,apache不再启动。
然后,我尝试了service apache2 start
和service apache2 status
几次,但该服务无法再次启动:
root@Debian-86-jessie-64-LAMP ~ # systemctl status apache2.service
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2)
Drop-In: /lib/systemd/system/apache2.service.d
└─forking.conf
Active: failed (Result: exit-code) since Thu 2018-06-21 16:29:28 CEST; 20s
ago
Process: 28201 ExecStop=/etc/init.d/apache2 stop (code=exited,
status=0/SUCCESS)
Process: 27456 ExecReload=/etc/init.d/apache2 reload (code=exited,
status=1/FAILURE)
Process: 26270 ExecStart=/etc/init.d/apache2 start (code=exited,
status=0/SUCCESS)
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27456]: Reloading web
server: apache2 failed!
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27456]: Apache2 is not
running ... (warning).
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: apache2.service: control
process exited, code=exited status=1
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reload failed for LSB:
Apache2 web server.
Jun 21 16:25:00 Debian-86-jessie-64-LAMP systemd[1]: Started LSB: Apache2 web
server.
Jun 21 16:25:13 Debian-86-jessie-64-LAMP systemd[1]: Started LSB: Apache2 web
server.
Jun 21 16:26:33 Debian-86-jessie-64-LAMP systemd[1]: Started LSB: Apache2 web
server.
Jun 21 16:29:28 Debian-86-jessie-64-LAMP apache2[28201]: Stopping web server:
apache2.
Jun 21 16:29:28 Debian-86-jessie-64-LAMP systemd[1]: Unit apache2.service
entered failed state.
几分钟后,systemctl restart apache2
工作了,一切都重新启动并运行了。我可以在上面的状态和下面将添加的journalctl中看到,有很多重新启动正在进行,但显然在那一点上失败了,但是基于该信息,我并不十分了解apache的原因是什么几分钟后将不会重新启动。 有什么我能防止将来发生的事情吗?(除了避免一切重新运行后不必要的重新加载,或者上载有错误的vhost.conf文件。)
journalctl(摘录):
Jun 21 16:24:25 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27363]: Reloading web
server: apache2.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reloaded LSB: Apache2
web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27388]: Reloading web
server: apache2 failed!
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27388]: Apache2 is not
running ... (warning).
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: apache2.service: control
process exited, code=exited status=1
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reload failed for LSB:
Apache2 web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27432]: Reloading web
server: apache2 failed!
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27432]: Apache2 is not
running ... (warning).
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: apache2.service: control
process exited, code=exited status=1
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reload failed for LSB:
Apache2 web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reloading LSB: Apache2
web server.
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27456]: Reloading web
server: apache2 failed!
Jun 21 16:24:26 Debian-86-jessie-64-LAMP apache2[27456]: Apache2 is not
running ... (warning).
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: apache2.service: control
process exited, code=exited status=1
Jun 21 16:24:26 Debian-86-jessie-64-LAMP systemd[1]: Reload failed for LSB:
Apache2 web server.
Jun 21 16:25:00 Debian-86-jessie-64-LAMP systemd[1]: Started LSB: Apache2 web
server.
[...]
Jun 21 16:25:13 Debian-86-jessie-64-LAMP systemd[1]: Started LSB: Apache2 web
server.
[...]
Jun 21 16:26:33 Debian-86-jessie-64-LAMP systemd[1]: Started LSB: Apache2 web
server.
[...]
Jun 21 16:29:28 Debian-86-jessie-64-LAMP apache2[28201]: Stopping web server:
apache2.
Jun 21 16:29:28 Debian-86-jessie-64-LAMP systemd[1]: Unit apache2.service
entered failed state.
[...]
Jun 21 16:33:12 Debian-86-jessie-64-LAMP systemd[1]: Starting Session 152810
of user root.
Jun 21 16:33:12 Debian-86-jessie-64-LAMP systemd-logind[859]: New session
152810 of user root.
Jun 21 16:33:12 Debian-86-jessie-64-LAMP systemd[1]: Started Session 152810
of user root.
Jun 21 16:33:54 Debian-86-jessie-64-LAMP systemd[1]: Starting LSB: Apache2
web server...
Jun 21 16:33:55 Debian-86-jessie-64-LAMP apache2[28734]: Starting web server:
apache2AH00558: apache2: Could not reliably determine the server's fully
qualified domain name, using 2a01:4f8:172:3388::2. Set the 'ServerName'
directive glob
Jun 21 16:33:56 Debian-86-jessie-64-LAMP apache2[28734]: .
Jun 21 16:33:56 Debian-86-jessie-64-LAMP systemd[1]: Started LSB: Apache2 web
server.
我也在apache日志中找到了这个
[Thu Jun 21 16:24:26.096119 2018] [mpm_prefork:notice] [pid 26286] AH00171:
Graceful restart requested, doing restart
AH00558: apache2: Could not reliably determine the server's fully qualified
domain name, using xxxxxxxxxx. Set the 'ServerName' directive
globally to suppress this message
[Thu Jun 21 16:24:26.131930 2018] [ssl:emerg] [pid 26286] AH02311: Fatal
error initialising mod_ssl, exiting. See
/var/log/apache2/chimney_es_ssl.error.log for more information
[Thu Jun 21 16:24:26.131933 2018] [:emerg] [pid 26286] AH00020: Configuration
Failed, exiting
我想那是由于我的.conf文件中的错误所致-我由于缺少证书而将ssl部分注释掉了,我想我也忘记了注释SSL Engine On
。
然后:(大约10分钟后)
[Thu Jun 21 16:33:55.118245 2018] [core:warn] [pid 28750] AH00098: pid file
/var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous
Apache run?
[Thu Jun 21 16:33:55.119860 2018] [mpm_prefork:notice] [pid 28750] AH00163:
Apache/2.4.10 (Debian) OpenSSL/1.0.1t configured -- resuming normal
operations
[Thu Jun 21 16:33:55.119889 2018] [core:notice] [pid 28750] AH00094: Command
line: '/usr/sbin/apache2'