安装 phpmyadmin 后 Apache2 configtest 失败

Posted

技术标签:

【中文标题】安装 phpmyadmin 后 Apache2 configtest 失败【英文标题】:Apache2 configtest failed after installing phpmyadmin 【发布时间】:2017-05-26 16:53:40 【问题描述】:

您好,我正在尝试安装 phpmyadmin,然后我坚持 apache2 重新启动... 当我试图修复它时,我做了以下事情:

sudo apt-get remove apache2
sudo apt-get autoremove
sudo apt-get install apache2

然后:

sudo nano /etc/apache2/apache2.conf 

我在最后加了:

Include /etc/phpmyadmin/apache.conf

然后重启

/etc/init.d/apache2 restart

它仍然不起作用,所以我决定安装以下两个包:

apt-get install libapache2-mod-php5
apt-get install php5.6 libapache2-mod-php5.6

重启时有如下输出:

 * Restarting Apache httpd web server apache2                                    [fail] 
 * The apache2 configtest failed.
Output of config test was:
Segmentation fault (core dumped)
Action 'configtest' failed.
The Apache error log may have more information.

日志文件:

cat /var/log/apache2/access.log

127.0.0.1 - - [11/Jan/2017:19:17:01 +0100] "GET / HTTP/1.1" 200 3595 "-" "Mozilla/5.0 ($
127.0.0.1 - - [11/Jan/2017:19:17:01 +0100] "GET /icons/ubuntu-logo.png HTTP/1.1" 404 51$
127.0.0.1 - - [11/Jan/2017:19:17:01 +0100] "GET /favicon.ico HTTP/1.1" 404 500 "http://$
127.0.0.1 - - [11/Jan/2017:19:17:06 +0100] "GET /phpmyadmin HTTP/1.1" 404 499 "-" "Mozi$
127.0.0.1 - - [11/Jan/2017:19:17:56 +0100] "GET /phpmyadmin/setup/index.php HTTP/1.1" 4$
127.0.0.1 - - [11/Jan/2017:19:20:27 +0100] "GET /phpmyadmin HTTP/1.1" 404 500 "-" "Mozi$

错误日志的输出:

[Wed Jan 11 18:58:27.464400 2017] [mpm_prefork:notice] [pid 1174] AH00163: Apache/2.4.23 (Ubuntu) configured -- resuming normal operations
[Wed Jan 11 18:58:27.464420 2017] [core:notice] [pid 1174] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jan 11 19:19:27.443455 2017] [mpm_prefork:notice] [pid 1174] AH00169: caught SIGTERM, shutting down
[Wed Jan 11 19:20:18.120230 2017] [mpm_prefork:notice] [pid 4527] AH00163: Apache/2.4.23 (Ubuntu) configured -- resuming normal operations
[Wed Jan 11 19:20:18.120268 2017] [core:notice] [pid 4527] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jan 11 19:21:19.771711 2017] [mpm_prefork:notice] [pid 4527] AH00171: Graceful restart requested, doing restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
[Wed Jan 11 19:21:19.787009 2017] [mpm_prefork:notice] [pid 4527] AH00163: Apache/2.4.23 (Ubuntu) configured -- resuming normal operations
[Wed Jan 11 19:21:19.787018 2017] [core:notice] [pid 4527] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jan 11 19:21:20.670808 2017] [mpm_prefork:notice] [pid 4527] AH00169: caught SIGTERM, shutting down

我正在开发elementaryOS。有谁知道在这种情况下该怎么办?

【问题讨论】:

检查错误日志而不是访问日志。也可以试试apachectl configtest @aynber apachectl configtest 提供与重新启动服务相同的输出。 【参考方案1】:
    通过定位目录检查您安装了多少个 php 以及在 apache 中需要/启用哪个:ls /etc/apache2/mods-enabled 禁用不需要的 php 模块。在我的情况下是 php5(我必须使用 php7.1 而不是 php5),所以输入:a2dismod php5 然后重新启动您的 apache 服务器:/etc/init.d/apache2 restart

【讨论】:

以上是关于安装 phpmyadmin 后 Apache2 configtest 失败的主要内容,如果未能解决你的问题,请参考以下文章

安装 phpmyadmin 后更改服务器选择

Ubuntu 14.04 服务器:phpMyAdmin 的 Apache2 问题

PHP+Apache2.x+phpMyAdmin安装和配置

在 Windows 10 和 Apache2 上运行 phpMyAdmin 时出现问题

CentOS 6.6编译安装LAMP(Apache2+PHP+Mysql+PHPmyAdmin)

关于Apache2.4版本的phpMyAdmin的配置