apache 尽管配置有效,但httpd.service失败(错误:AH00016:配置失败)

w6lpcovy  于 2023-06-24  发布在  Apache
关注(0)|答案(1)|浏览(271)

最近,我在为我的Flask应用程序服务的Apache服务器启动httpd服务时出错。它运行在AWS EC2示例上。它是工作上周,然后我试图添加SSL到我的服务器,它没有立即工作。这不是一个大问题,所以我决定现在坚持使用常规HTTP,因为我赶时间。但是现在我得到了以下错误,没有有用的日志信息:

  1. httpd.service - The Apache HTTP Server
  2. Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  3. Active: failed (Result: exit-code) since Tue 2023-06-13 01:10:05 UTC; 15s ago
  4. Docs: man:httpd.service(8)
  5. Process: 2298 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
  6. Main PID: 2298 (code=exited, status=1/FAILURE)
  7. Status: "Reading configuration..."
  8. Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: Starting The Apache HTTP Server...
  9. Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: httpd.service: main process exited, code=exit...RE
  10. Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: Failed to start The Apache HTTP Server.
  11. Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: Unit httpd.service entered failed state.
  12. Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: httpd.service failed.

这是我的httpd.conf

  1. <VirtualHost *:80>
  2. WSGIDaemonProcess ocr_api python-path=/var/www/html/ocr_api:/var/www/html/ocr/lib/python3.7/site-packages
  3. ServerName ******
  4. WSGIScriptAlias /ocr_api /var/www/html/ocr_api/api.wsgi
  5. <Directory /var/www/html/ocr_api/>
  6. Options +Indexes +FollowSymLinks
  7. AllowOverride All
  8. Require all granted
  9. </Directory>
  10. ErrorLog custom_logs/ocr_error.log
  11. </VirtualHost>

当运行sudo httpd -t时,我得到了Syntax OK,所以我不确定apache到底有什么问题??
当我检查错误日志时,我看到了以下内容:AH00016: Configuration Failed

zte4gxcn

zte4gxcn1#

好了,我找到了问题所在,对于将来来到这里的任何人,我最初都忽略了检查/etc/httpd/logs/ssl_error_log下的ssl日志,其中显示了错误:AH02565: Certificate and private key ip-172-**-**-**.us-east-, 2.compute.internal:443:0 from /etc/pki/tls/certs/localhost.crt and /etc/pki/tls/private/localhost.key do not match
所以我重新生成了自签名证书,如下所示:openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/pki/tls/private/localhost.key -out /etc/ssl/certs/localhost.crt - reference
现在它起作用了。

相关问题