【发布时间】:2023-03-20 15:22:02
【问题描述】:
通过 Certbot 安装 SSL 证书后,我的网站出现错误消息“重定向过多”。经过一些研究,我认为我必须在某个地方从 HTTPS -> HTTP 重定向,所以我尝试修复它,但似乎我让它变得更糟,Apache 将不再启动。我是一个初学者,所以我很难理解哪里出了问题。
我正在设置一个通过 SSH 访问 CentOS7 的 VPS,以托管一个简单的 html 网站。我设置了基础知识(相关的可能是 UFW 防火墙、作为 DNS 的 Cloudflare、Apache 2.4.6)并设法在我的域上显示了一个测试页面。
然后我继续使用本教程设置我的虚拟主机:https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7 按照本教程设置letsencrypt:https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-centos-7
在此之后,我最初在尝试访问以前正常工作的域时收到错误消息“重定向太多”。在尝试连续四个小时解决此问题时,我现在把事情搞砸了,以至于 Apache 似乎无法启动。
现在,当我执行$ sudo systemctl restart httpd 时,我收到错误消息“httpd.service 的作业失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status httpd.service”和“journalctl -xe”。”
[USER@host ~]$ sudo systemctl status httpd.service
* httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2019-01-23 00:57:39 UTC; 20s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 26023 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 24468 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
Process: 26021 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 26021 (code=exited, status=1/FAILURE)
Jan 23 00:57:39 host systemd[1]: Starting The Apache HTTP Server...
Jan 23 00:57:39 host systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 23 00:57:39 host kill[26023]: kill: cannot find process ""
Jan 23 00:57:39 host systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 23 00:57:39 host systemd[1]: Failed to start The Apache HTTP Server.
Jan 23 00:57:39 host systemd[1]: Unit httpd.service entered failed state.
Jan 23 00:57:39 host systemd[1]: httpd.service failed.
我对@987654325@ 所做的唯一更改是将底部的IncludeOptional conf.d/*.conf 更改为IncludeOptional sites-enabled/*.conf
我的虚拟主机设置目前如下:
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/example.com/public_html
Redirect / https://www.example.com/
</VirtualHost>
<VirtualHost _default_:443>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/requests.log combined
SSLEngine on
</VirtualHost>
如果有任何可能出现问题的指示,将不胜感激。
【问题讨论】:
-
在 apache 配置(SSL 部分)中,您没有定义证书、密钥和中间证书)
-
添加为答案。如果这对您有用,请随意添加和/或接受答案