我正在对 Apache 进行更改并删除了配置。Apache 无法工作。因此,我将其删除并重新安装。Apache 可以工作。Mysql 可以工作。但是,PHP 测试无法工作。php 测试文件位于 /var/www/html 中,但无法显示。 http://localhost/test2.php在浏览器中只给我一个空白屏幕。
重新安装 PHP 似乎没有帮助。我只看到一个空白屏幕,没有错误消息。WordPress 也没有出现。
有什么建议么?
错误日志:
[Sun Nov 05 16:34:24.764857 2017] [mpm_event:notice] [pid 3887:tid 140535676766080] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Sun Nov 05 16:34:24.764954 2017] [core:notice] [pid 3887:tid 140535676766080] AH00094: Command line: '/usr/sbin/apache2'
[Sun Nov 05 16:37:41.761332 2017] [mpm_event:notice] [pid 3887:tid 140535676766080] AH00491: caught SIGTERM, shutting down
[Sun Nov 05 16:37:42.834654 2017] [mpm_event:notice] [pid 4105:tid 140542285068160] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Sun Nov 05 16:37:42.834749 2017] [core:notice] [pid 4105:tid 140542285068160] AH00094: Command line: '/usr/sbin/apache2'
[Sun Nov 05 16:57:35.990992 2017] [mpm_event:notice] [pid 4105:tid 140542285068160] AH00491: caught SIGTERM, shutting down
[Sun Nov 05 16:57:37.056553 2017] [mpm_event:notice] [pid 4647:tid 140007533836160] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Sun Nov 05 16:57:37.056632 2017] [core:notice] [pid 4647:tid 140007533836160] AH00094: Command line: '/usr/sbin/apache2'
[Sun Nov 05 18:01:18.870157 2017] [mpm_event:notice] [pid 4647:tid 140007533836160] AH00491: caught SIGTERM, shutting down
[Sun Nov 05 18:01:19.944634 2017] [mpm_event:notice] [pid 6272:tid 140286123997056] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Sun Nov 05 18:01:19.944719 2017] [core:notice] [pid 6272:tid 140286123997056] AH00094: Command line: '/usr/sbin/apache2'
[Sun Nov 05 18:07:31.641146 2017] [mpm_event:notice] [pid 6272:tid 140286123997056] AH00491: caught SIGTERM, shutting down
[Mon Nov 06 06:55:45.343332 2017] [mpm_event:notice] [pid 1031:tid 139664376633216] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Mon Nov 06 06:55:45.366228 2017] [core:notice] [pid 1031:tid 139664376633216] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 06 07:00:30.525862 2017] [mpm_event:notice] [pid 1031:tid 139664376633216] AH00493: SIGUSR1 received. Doing graceful restart
答案1
尝试安装并启用php模块,重新启动Apache:
sudo apt install libapache2-mod-php7.0
sudo a2enmod php7.0
sudo systemctl restart apache2.service
然后尝试<?php phpinfo(); ?>
再次访问您的页面。
上述命令的作用如下:
apt install libapache2-mod-php7.0
- 安装 Apache 的 php7.0 版 PHP 模块。a2enmod php7.0
- 启用模块 - 此命令将为模块的文件创建一个从/etc/apache2/mods-available
到的符号链接/etc/apache2/mods-enabled
。systemctl restart apache2.service
- 重新启动 Apache 以接受新配置(可以只是reload
)。目录中的所有模块都通过以下指令
/etc/apache2/mods-enabled
包含在 Apache 的主配置文件中:/etc/apache2/apache2.conf
IncludeOptional mods-enabled/*.load IncludeOptional mods-enabled/*.conf