0

问题

Ubuntu 16.04 中的 Apache2 无法启动,我收到一个非常通用的非描述性错误,不知道该怎么办?

日志/错误

apache2重启

systemctl restart apache2.service给出错误...

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

阿帕奇2状态

systemctl status apache2.service给出错误...

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-01-03 02:35:00 UTC; 1min 55s ago
  Process: 28312 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

Jan 03 02:35:00 web3 systemd[1]: Starting The Apache HTTP Server...
Jan 03 02:35:00 web3 apachectl[28312]: Action 'start' failed.
Jan 03 02:35:00 web3 apachectl[28312]: The Apache error log may have more information.
Jan 03 02:35:00 web3 systemd[1]: apache2.service: Control process exited, code=exited status=1
Jan 03 02:35:00 web3 systemd[1]: Failed to start The Apache HTTP Server.
Jan 03 02:35:00 web3 systemd[1]: apache2.service: Unit entered failed state.
Jan 03 02:35:00 web3 systemd[1]: apache2.service: Failed with result 'exit-code'.

journalctl -xe

journalctl -xe给出错误...

几乎相同systemctl restart apache2.service

/var/log/apache2/error.log

/var/log/apache2/error.log给出错误...

AH00016: Configuration Failed

apachectl -t

确保 Aapche2 语法没问题...

apachectl -tapachectl configtest返回...

Syntax OK

APACHE2 配置文件(其余相同)

现在,这里是 Apache2 conf 文件之一的内容。其他的都差不多。我在fcgid模式下运行一切。还要注意我Protocols h2 h2c http/1.1在这里。

/etc/apache2/sites-available/example.com.conf

<VirtualHost 123.123.123.123:80>
SuexecUserGroup "#1917" "#1917"
ServerName example.com
ServerAlias www.example.com
ServerAlias webmail.example.com
ServerAlias admin.example.com
DocumentRoot /home/example/public_html
ErrorLog /var/log/virtualmin/example.com_error_log
CustomLog /var/log/virtualmin/example.com_access_log combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
Protocols h2 h2c http/1.1
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^\w+\.\w+\.\w+ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]
RewriteCond %{HTTP_HOST} =webmail.example.com
RewriteRule ^(.*) https://example.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.example.com
RewriteRule ^(.*) https://example.com:10000/ [R]
<Directory /home/example/public_html>
Options -Indexes +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5.6
AddHandler fcgid-script .php7.0
AddHandler fcgid-script .php7.1
AddHandler fcgid-script .php7.2
AddHandler fcgid-script .php7.3
FCGIWrapper /home/example/fcgi-bin/php7.3.fcgi .php
FCGIWrapper /home/example/fcgi-bin/php5.6.fcgi .php5.6
FCGIWrapper /home/example/fcgi-bin/php7.0.fcgi .php7.0
FCGIWrapper /home/example/fcgi-bin/php7.1.fcgi .php7.1
FCGIWrapper /home/example/fcgi-bin/php7.2.fcgi .php7.2
FCGIWrapper /home/example/fcgi-bin/php7.3.fcgi .php7.3
</Directory>
<Directory /home/example/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
<IfModule php5_module>
php_value newrelic.appname "example.com"
</IfModule>
RemoveHandler .php
RemoveHandler .php5.6
RemoveHandler .php7.0
RemoveHandler .php7.1
RemoveHandler .php7.2
RemoveHandler .php7.3
IPCCommTimeout 25001
FcgidMaxRequestLen 1073741824
</VirtualHost>
<VirtualHost 123.123.123.123:443>
SuexecUserGroup "#1917" "#1917"
ServerName example.com
ServerAlias www.example.com
ServerAlias webmail.example.com
ServerAlias admin.example.com
DocumentRoot /home/example/public_html
ErrorLog /var/log/virtualmin/example.com_error_log
CustomLog /var/log/virtualmin/example.com_access_log combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
Protocols h2 h2c http/1.1
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^\w+\.\w+\.\w+ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]
RewriteCond %{HTTP_HOST} =webmail.example.com
RewriteRule ^(.*) https://example.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.example.com
RewriteRule ^(.*) https://example.com:10000/ [R]
<Directory /home/example/public_html>
Options -Indexes +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5.6
AddHandler fcgid-script .php7.0
AddHandler fcgid-script .php7.1
AddHandler fcgid-script .php7.2
AddHandler fcgid-script .php7.3
FCGIWrapper /home/example/fcgi-bin/php7.3.fcgi .php
FCGIWrapper /home/example/fcgi-bin/php5.6.fcgi .php5.6
FCGIWrapper /home/example/fcgi-bin/php7.0.fcgi .php7.0
FCGIWrapper /home/example/fcgi-bin/php7.1.fcgi .php7.1
FCGIWrapper /home/example/fcgi-bin/php7.2.fcgi .php7.2
FCGIWrapper /home/example/fcgi-bin/php7.3.fcgi .php7.3
</Directory>
<Directory /home/example/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
<IfModule php5_module>
php_value newrelic.appname "example.com"
</IfModule>
RemoveHandler .php
RemoveHandler .php5.6
SSLEngine on
SSLCertificateFile /home/example/ssl.cert
SSLCertificateKeyFile /home/example/ssl.key
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
RemoveHandler .php7.0
RemoveHandler .php7.1
RemoveHandler .php7.2
RemoveHandler .php7.3
IPCCommTimeout 25001
FcgidMaxRequestLen 1073741824
</VirtualHost>

我安装的操作系统和概述

APACHE2 和 PHP 模块

apache2ctl -M | 种类

 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 core_module (static)
 dav_fs_module (shared)
 dav_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 fcgid_module (shared)
 filter_module (shared)
 http2_module (shared)
 http_module (static)
 lbmethod_byrequests_module (shared)
 log_config_module (static)
 logio_module (static)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 proxy_balancer_module (shared)
 proxy_connect_module (shared)
 proxy_fcgi_module (shared)
 proxy_http_module (shared)
 proxy_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 slotmem_shm_module (shared)
 socache_shmcb_module (shared)
 so_module (static)
 ssl_module (shared)
 status_module (shared)
 suexec_module (shared)
 unixd_module (static)
 version_module (static)
 watchdog_module (static)

php -m

[PHP Modules]
bcmath
calendar
Core
ctype
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
pspell
readline
recode
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
zlib

[Zend Modules]
Xdebug

apt 列表--已安装 | grep php

libapache2-mod-php5.6/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
libapache2-mod-php7.0/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
libapache2-mod-php7.1/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
libapache2-mod-php7.2/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
libapache2-mod-php7.3/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php/xenial,now 2:7.2+69+ubuntu16.04.1+deb.sury.org+1 all [installed]
php-cgi/xenial,now 2:7.2+69+ubuntu16.04.1+deb.sury.org+1 all [installed]
php-cli/xenial,now 2:7.2+69+ubuntu16.04.1+deb.sury.org+1 all [installed,automatic]
php-common/xenial,now 2:69+ubuntu16.04.1+deb.sury.org+1 all [installed,automatic]
php-mbstring/xenial,now 2:7.2+69+ubuntu16.04.1+deb.sury.org+1 all [installed,automatic]
php-mcrypt/xenial-updates,now 1:7.0+35ubuntu6.1 all [installed]
php-mysql/xenial,now 2:7.2+69+ubuntu16.04.1+deb.sury.org+1 all [installed,automatic]
php-pear/xenial,now 1:1.10.6+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+2 all [installed,automatic]
php-xdebug/xenial,now 2.7.0~beta1+2.6.1+2.5.5-1+ubuntu16.04.1+deb.sury.org+10 amd64 [installed]
php-xml/xenial,now 2:7.2+69+ubuntu16.04.1+deb.sury.org+1 all [installed,automatic]
php-zip/xenial,now 2:7.2+69+ubuntu16.04.1+deb.sury.org+1 all [installed]
php5.6/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 all [installed]
php5.6-bcmath/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-cli/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-common/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-fpm/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-gd/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-intl/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-json/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-mbstring/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-mcrypt/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-mysql/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-opcache/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php5.6-pspell/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-readline/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php5.6-recode/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-soap/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-xml/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php5.6-xmlrpc/xenial,now 5.6.39-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 all [installed]
php7.0-bcmath/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-cgi/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-cli/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-common/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-fpm/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-gd/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-intl/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-json/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-mbstring/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-mcrypt/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-mysql/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-opcache/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-pspell/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-readline/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-recode/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-soap/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.0-xml/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.0-xmlrpc/xenial,now 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 all [installed]
php7.1-bcmath/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-cli/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-common/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-fpm/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-gd/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-intl/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-json/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-mbstring/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-mcrypt/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-mysql/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-opcache/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.1-pspell/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-readline/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.1-recode/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-soap/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-xml/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-xmlrpc/xenial,now 7.1.25-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 all [installed]
php7.2-bcmath/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-cgi/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.2-cli/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-common/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-fpm/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-gd/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-intl/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-json/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-mbstring/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-mysql/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-opcache/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.2-pspell/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-readline/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.2-recode/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-soap/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-xml/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-xmlrpc/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.2-zip/xenial,now 7.2.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.3/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 all [installed]
php7.3-bcmath/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-cli/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-common/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-fpm/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-gd/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-intl/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-json/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-mbstring/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-mysql/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-opcache/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.3-pspell/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-readline/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.3-recode/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-soap/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-xml/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.3-xmlrpc/xenial,now 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
webmin-php-pear/virtualmin-universal,now 1.5 all [installed,automatic]
4

1 回答 1

0

如果在运行 configtest 命令时得到 Syntax OK,这意味着 Apache 配置的语法没有任何问题,但这意味着 SSL 证书没有正确安装,或者更通用的配置文件有问题阿帕奇的。

调试和查看发生了什么的一种简单方法是使用 strace 命令:

sudo apt-get update
sudo apt-get install strace
sudo strace -f apache2ctl start

输出很长,但你肯定能看到 apache 失败的地方以及为什么......

于 2019-02-13T14:10:09.950 回答