Apache2没有运行

Apache2没有运行,apache2,lets-encrypt,ubuntu-18.04,php-7.2,fpm,Apache2,Lets Encrypt,Ubuntu 18.04,Php 7.2,Fpm,我正在用Ubuntu18.04运行Apache2 LAMP服务器,突然在没有任何警告的情况下,Apache停止运行。我试图找出sudo服务apache2状态的问题,它显示了以下内容: sudo service apache2 status ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled

我正在用Ubuntu18.04运行Apache2 LAMP服务器,突然在没有任何警告的情况下,Apache停止运行。我试图找出sudo服务apache2状态的问题,它显示了以下内容:

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
httpd not running, trying to start
Action 'restart' failed.
The Apache error log may have more information.
我要做的第一件事是尝试使用sudo apachectl restart手动启动它,结果如下:

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
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,但没有成功。我正在运行php7.2和php7.0-fpm,对于SSL,我已经安装了加密Certbot


外面有人能告诉我发生了什么吗?

发现了问题,在我的apache配置文件中有一个损坏的代码

对于那些有相同问题的人,以下是解决方法:

使用cd/etc/Apache2/sites available转到Apache2站点可用目录 使用sudo a2dispate example.com.conf example-2.com.conf禁用所有配置文件。。。现在忽略systemctl重新加载apache2,我们稍后再讨论 使用sudo a2ensite 000-default.conf启用默认配置文件 使用sudo systemctl重新加载Apache2 使用sudo a2ensite test-1.conf逐个启用配置文件,找出哪个文件已损坏,并使用sudo systemctl reload apache2重新加载apache,最后测试它是否正在使用sudo服务apache2状态 找到文件后,编辑它,修复问题并关闭以启用所有配置文件!确保使用sudo a2dispate 000-default.conf禁用默认设置,检查Apache是否在sudo服务apache2状态下运行。 给你!反正我就是这样修好的。哦,禁用和启用配置文件可能会导致指向错误的目录,当您重新启用所有配置文件时,应该会恢复正常

祝你今天愉快:D