最近,我在为我的Flask应用程序服务的Apache服务器启动httpd服务时出错。它运行在AWS EC2示例上。它是工作上周,然后我试图添加SSL到我的服务器,它没有立即工作。这不是一个大问题,所以我决定现在坚持使用常规HTTP,因为我赶时间。但是现在我得到了以下错误,没有有用的日志信息:
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2023-06-13 01:10:05 UTC; 15s ago
Docs: man:httpd.service(8)
Process: 2298 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 2298 (code=exited, status=1/FAILURE)
Status: "Reading configuration..."
Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: Starting The Apache HTTP Server...
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
Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: Failed to start The Apache HTTP Server.
Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: Unit httpd.service entered failed state.
Jun 13 01:10:05 ip-172-31-40-174.us-east-2.compute.internal systemd[1]: httpd.service failed.
这是我的httpd.conf
:
<VirtualHost *:80>
WSGIDaemonProcess ocr_api python-path=/var/www/html/ocr_api:/var/www/html/ocr/lib/python3.7/site-packages
ServerName ******
WSGIScriptAlias /ocr_api /var/www/html/ocr_api/api.wsgi
<Directory /var/www/html/ocr_api/>
Options +Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog custom_logs/ocr_error.log
</VirtualHost>
当运行sudo httpd -t
时,我得到了Syntax OK
,所以我不确定apache到底有什么问题??
当我检查错误日志时,我看到了以下内容:AH00016: Configuration Failed
1条答案
按热度按时间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现在它起作用了。