【发布时间】:2018-11-22 22:53:27
【问题描述】:
我的服务器 (Apache/Ubuntu) 使用纯 http 运行良好,但当我尝试添加 https 证书和配置时无法启动。
sudo service apache2 start
Job for apache2.service failed because the control process exited with error
code. See "systemctl status apache2.service" and "journalctl -xe" for details.
这给出了:
> sudo journalctl | tail
Jun 13 10:56:28 apache2[11045]: Action 'configtest' failed.
Jun 13 10:56:28 apache2[11045]: The Apache error log may have more information.
Jun 13 10:56:28 systemd[1]: apache2.service: Control process exited, code=exited status=1
Jun 13 10:56:28 sudo[11015]: pam_unix(sudo:session): session closed for user root
Jun 13 10:56:28 systemd[1]: Failed to start LSB: Apache2 web server.
Jun 13 10:56:28 systemd[1]: apache2.service: Unit entered failed state.
Jun 13 10:56:28 systemd[1]: apache2.service: Failed with result 'exit-code'.
还有:
> systemctl status apache2.service
● 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 Wed 2018-06-13 10:56:28 UTC; 1min 48s ago
Docs: man:systemd-sysv-generator(8)
Process: 10676 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 8285 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
Process: 11045 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
我的 000-default.conf 如下所示:
<VirtualHost *:80>
ServerName myserver.com
DocumentRoot /var/www/html/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName myserver.com
DocumentRoot /var/www/html/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /var/www/html/crt/domain.cert
SSLCertificateKeyFile /var/www/html/crt/domain.key
SSLCACertificateFile /var/www/html/crt/domain.cacert
</VirtualHost>
至少目前,我为 www-data 用户和组授予了证书文件夹 770 中的所有内容。只是为了消除权限问题。看起来SSLEngine on 语句是触发错误的原因。
Apache 错误日志中没有更多信息(可能是因为它一开始没有启动。
【问题讨论】:
-
apache2ctl configtest会告诉你配置文件有什么问题。