HTTP 进行重定向,所以我试图修复它,但似乎我把它弄得更糟了-6ren">
gpt4 book ai didi

apache - "Job for httpd.service failed because the control process exited with error code."我该如何解决这个问题?

转载 作者:太空宇宙 更新时间:2023-11-03 13:59:54 31 4
gpt4 key购买 nike

通过 Certbot 安装 SSL 证书后,我的网站出现错误消息“太多重定向”。经过一些研究,我认为我必须在某个地方从 HTTPS -> HTTP 进行重定向,所以我试图修复它,但似乎我把它弄得更糟了,Apache 将不再启动。我是一个完全的初学者,所以我很难理解哪里出了问题。

我正在使用通过 SSH 访问的 CentOS7 设置一个 VPS 来托管一个简单的 html 网站。我设置了基础(相关的可能是 UFW 防火墙、Cloudflare 作为 DNS、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 时,我收到错误消息“Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service"and "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.

我对 /etc/httpd/conf/httpd.conf 所做的唯一更改是将底部的 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>

如有任何错误提示,我们将不胜感激。

最佳答案

因为我使用了 letsencrypt,它看起来像这样:

    SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem

这解决了 apache 的错误。虽然 SSL 加密还没有工作,但如果我发现这是这些行的问题,我会回来更新它。

编辑:此设置现在对我来说工作正常。 SSL 加密不起作用的问题是由于 Cloudflare 中的 SSL 处于“关闭”状态,这造成了重定向循环。

关于apache - "Job for httpd.service failed because the control process exited with error code."我该如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54318998/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com