我的 SSL 虚拟主机就这么简单:
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
DocumentRoot "/srv/www/test"
ServerName <my_website_domain>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
</VirtualHost>
当我尝试重新启动 apache 时,apache2ctl configtest && systemctl restart apache2
我得到:
apache2.service 的语法 OK
作业失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status apache2.service”和“journalctl -xe”。
但是当我用 apache 关闭 SSLEngine 时,它SSLEngine off
可以正常启动并且正常。
当我systemctl status apache2
从 开始后运行时SSLEngine on
,我得到:
Syntax OK
● apache2.service - The Apache Webserver
Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-08-14 18:06:55 CEST; 1min 9s ago
Process: 22352 ExecStop=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful-stop (code=exited, status=0/SUCCESS)
Process: 19851 ExecReload=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful (code=exited, status=0/SUCCESS)
Process: 22346 ExecStart=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k start (code=exited, status=1/FAILURE)
Main PID: 22346 (code=exited, status=1/FAILURE)
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351148 2020] [so:warn] [pid 22352] AH01574: module authn_core_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351163 2020] [so:warn] [pid 22352] AH01574: module authz_core_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351170 2020] [so:warn] [pid 22352] AH01574: module php5_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.351179 2020] [so:warn] [pid 22352] AH01574: module ssl_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.352998 2020] [so:warn] [pid 22352] AH01574: module ssl_module is already loaded, skipping
Aug 14 18:06:55 luu056d start_apache2[22352]: [Fri Aug 14 18:06:55.356261 2020] [core:warn] [pid 22352] AH00117: Ignoring deprecated use of DefaultType in line 143 of /etc/apa.../httpd.conf.
Aug 14 18:06:55 luu056d start_apache2[22352]: httpd (no pid file) not running
Aug 14 18:06:55 luu056d systemd[1]: Failed to start The Apache Webserver.
Aug 14 18:06:55 luu056d systemd[1]: apache2.service: Unit entered failed state.
Aug 14 18:06:55 luu056d systemd[1]: apache2.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
为什么我httpd (no pid file) not running
开机时会出现这个错误SSLEngine
?
没有任何东西阻塞端口 443,因为当我运行时lsof -i :443
结果为空。
我正在为 Linux/SUSE 使用 Apache/2.4.23
这表明证书有问题,httpd 无法加载它们,因此无法正常启动。通常,这些错误不会显示,除非您对 SSL 进行高级别的错误日志记录。只需设置
LogLevel ssl:trace8
为测试并在您开始工作时将其删除。确保证书是 PEM 格式 (ASCII),它们相互匹配并且存在于您指向它们的路径中:
两个命令的输出应该返回相同的结果,如果不是,它们是不正确的。
我要感谢所有其他回复的人,但问题存在于文件中
ssl-globals.conf
。这两个指令使 apache 崩溃
我刚刚评论了他们,现在它正在工作。我不知道为什么,但科学是基于证据的。