Apache2没有运行

问题描述 投票:0回答:1

我正在使用Ubuntu 18.04运行Apache2 LAMP服务器,并且突然没有警告,Apache停止运行。我尝试用sudo service apache2 status解决问题,它显示以下内容:

sudo service apache2 status
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Mon 2018-09-03 13:07:40 UTC; 1h 6min ago
  Process: 55939 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
 Main PID: 128448 (code=exited, status=1/FAILURE)

Sep 03 13:07:40 localhost systemd[1]: Starting The Apache HTTP Server...
Sep 03 13:07:40 localhost apachectl[55939]: Action 'start' failed.
Sep 03 13:07:40 localhost apachectl[55939]: The Apache error log may have more information.
Sep 03 13:07:40 localhost systemd[1]: apache2.service: Control process exited, code=exited status=1
Sep 03 13:07:40 localhost systemd[1]: apache2.service: Failed with result 'exit-code'.
Sep 03 13:07:40 localhost systemd[1]: Failed to start The Apache HTTP Server.

我做的第一件事是尝试用sudo apachectl restart手动启动它,结果如下:

sudo apachectl restart
httpd not running, trying to start
Action 'restart' failed.
The Apache error log may have more information.

所以我用sudo view /var/log/apache2/error.log检查日志,它显示了一个很长的列表,如下所示:

PHP Warning:  Module 'mbstring' already loaded in Unknown on line 0
PHP Warning:  Module 'xmlrpc' already loaded in Unknown on line 0
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
[Mon Sep 03 06:25:03.860913 2018] [ssl:emerg] [pid 128448] AH02572: Failed to configure at least one certificate and key for hailiga.org:443
[Mon Sep 03 06:25:03.860996 2018] [ssl:emerg] [pid 128448] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 06:25:03.861009 2018] [ssl:emerg] [pid 128448] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 06:25:03.861060 2018] [ssl:emerg] [pid 128448] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Mon Sep 03 06:25:03.861077 2018] [ssl:emerg] [pid 128448] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
[Mon Sep 03 06:25:03.861086 2018] [:emerg] [pid 128448] AH00020: Configuration Failed, exiting
[Mon Sep 03 06:41:32.662021 2018] [ssl:emerg] [pid 53226] AH02572: Failed to configure at least one certificate and key for hailiga.org:443
[Mon Sep 03 06:41:32.662102 2018] [ssl:emerg] [pid 53226] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 06:41:32.662112 2018] [ssl:emerg] [pid 53226] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 06:41:32.662122 2018] [ssl:emerg] [pid 53226] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Mon Sep 03 06:41:32.662127 2018] [ssl:emerg] [pid 53226] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
AH00016: Configuration Failed
[Mon Sep 03 13:05:09.612981 2018] [ssl:emerg] [pid 55512] AH02572: Failed to configure at least one certificate and key for hailiga.org:443
[Mon Sep 03 13:05:09.613049 2018] [ssl:emerg] [pid 55512] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:05:09.613058 2018] [ssl:emerg] [pid 55512] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:05:09.613068 2018] [ssl:emerg] [pid 55512] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Mon Sep 03 13:05:09.613072 2018] [ssl:emerg] [pid 55512] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
AH00016: Configuration Failed
[Mon Sep 03 13:07:40.617846 2018] [ssl:emerg] [pid 55942] AH02572: Failed to configure at least one certificate and key for hailiga.org:443
[Mon Sep 03 13:07:40.618439 2018] [ssl:emerg] [pid 55942] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:07:40.618451 2018] [ssl:emerg] [pid 55942] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:07:40.618461 2018] [ssl:emerg] [pid 55942] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Mon Sep 03 13:07:40.618466 2018] [ssl:emerg] [pid 55942] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
AH00016: Configuration Failed
[Mon Sep 03 13:14:43.673776 2018] [ssl:emerg] [pid 56048] AH02572: Failed to configure at least one certificate and key for hailiga.org:443
[Mon Sep 03 13:14:43.673881 2018] [ssl:emerg] [pid 56048] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:14:43.673895 2018] [ssl:emerg] [pid 56048] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:14:43.673918 2018] [ssl:emerg] [pid 56048] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Mon Sep 03 13:14:43.673924 2018] [ssl:emerg] [pid 56048] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
AH00016: Configuration Failed
[Mon Sep 03 13:24:44.627730 2018] [ssl:emerg] [pid 56066] AH02572: Failed to configure at least one certificate and key for hailiga.org:443
[Mon Sep 03 13:24:44.627812 2018] [ssl:emerg] [pid 56066] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:24:44.627822 2018] [ssl:emerg] [pid 56066] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:24:44.627839 2018] [ssl:emerg] [pid 56066] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Mon Sep 03 13:24:44.627845 2018] [ssl:emerg] [pid 56066] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
AH00016: Configuration Failed
[Mon Sep 03 13:50:11.691451 2018] [ssl:emerg] [pid 56308] AH02572: Failed to configure at least one certificate and key for hailiga.org:443
[Mon Sep 03 13:50:11.691543 2018] [ssl:emerg] [pid 56308] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:50:11.691552 2018] [ssl:emerg] [pid 56308] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Mon Sep 03 13:50:11.691569 2018] [ssl:emerg] [pid 56308] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned
[Mon Sep 03 13:50:11.691574 2018] [ssl:emerg] [pid 56308] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information
AH00016: Configuration Failed
[Mon Sep 03 14:07:10.776987 2018] [ssl:emerg] [pid 56364] AH02572: Failed to configure at least one certificate and key for hailiga.org:443

我试过phpdismod三个错误模块,它没有用。我正在运行PHP 7.2和php7.0-fpm,因为SSL我安装了Let's Encrypt Certbot。

有人可以告诉我发生了什么事吗?

apache2 lets-encrypt ubuntu-18.04 php-7.2 fpm
1个回答
1
投票

发现问题,我的apache配置文件中的代码已损坏。

对于那些有相同问题的人,如何解决它:

  1. 使用cd /etc/apache2/sites-available转到Apache2站点可用目录
  2. 使用sudo a2dissite example.com.conf example-2.com.conf ...禁用所有配置文件(现在忽略systemctl reload apache2,我们稍后会介绍)
  3. 使用sudo a2ensite 000-default.conf启用默认配置文件
  4. sudo systemctl reload apache2重新加载Apache2
  5. 使用sudo a2ensite test-1.conf逐个启用配置文件,找出哪一个已损坏,并使用sudo systemctl reload apache2重新加载apache,最后测试它是否与sudo service apache2 status一起使用
  6. 一旦找到文件编辑它,修复问题并关闭以启用所有配置文件!请务必使用sudo a2dissite 000-default.conf禁用默认值,检查Apache是​​否正在运行sudo service apache2 status

你有它!无论如何,这就是我修复它的方式。哦,禁用和启用配置文件可能会导致指向错误的目录,当您启用所有这些目录时,它应该恢复正常。

祝你有美好的一天:D

© www.soinside.com 2019 - 2024. All rights reserved.