[英]Apache not starting with SSL virtualhost
我的服务器(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错误日志中没有更多信息(可能是因为它不是从头开始的)。
进一步走了几步。 最大的问题是缺少调试信息,但是以下命令会有所帮助:
sudo systemctl status apache2.service
我在SSLEngine
行中给出了语法错误。 显然,Ubuntu需要运行以下命令来启用ssl:
sudo a2enmod ssl
现在,apache服务器应该可以正常启动了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.