【问题标题】:Apache not starting with SSL virtualhostApache 没有从 SSL 虚拟主机开始
【发布时间】: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 会告诉你配置文件有什么问题。

标签: apache ubuntu ssl https


【解决方案1】:

还有几步。最大的问题是缺少调试信息,但以下命令很有帮助:

sudo systemctl status apache2.service

我在SSLEngine 行给出了一个语法错误。显然 Ubuntu 需要运行以下命令来启用 ssl:

sudo a2enmod ssl

现在apache服务器应该正常启动了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-07
    • 2016-11-05
    • 2020-10-18
    • 2014-12-29
    • 2010-10-05
    • 2013-01-27
    • 1970-01-01
    相关资源
    最近更新 更多