错误页面:
参考:https://serverfault.com/questions/883169/wordpress-does-not-execute-php-file
处理过程:
1) 修改配置,可以正常访问Apache默认页面
2) 怀疑PHP问题导致无法执行PHP代码,建立phpinfo以确定是否可以显示PHP版本信息。
sudo vi phpinfo.php
添加以下内容
<?php phpinfo(); ?>
将文件保存在Web root。
打开浏览器指定访问该文件。
页面一样无法显示PHP版本信息。
3) 参考网上案例,安装所有必要PHP模块
sudo apt install php-cli php-curl php-mbstring php-gd php-json php-xml php-pear
sudo systemctl restart apache2
但问题仍存在
4) 尝试重启fpm
service php-fmp restart
但提示服务不存在
Failed to restart php-fmp.service: Unit php-fmp.service not found.
5) 重新安装fmp
root@instance-220331152519:/etc/apache2# apt search php-fpm
Sorting... Done
Full Text Search... Done
php-cgi/focal,focal 2:7.4+75 all
server-side, HTML-embedded scripting language (CGI binary) (default)
php-fpm/focal,focal 2:7.4+75 all
server-side, HTML-embedded scripting language (FPM-CGI binary) (default)
root@instance-220331152519:/etc/apache2# apt install php-fpm -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
php7.4-fpm
The following NEW packages will be installed:
php-fpm php7.4-fpm
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,436 kB of archives.
After this operation, 4,881 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 php7.4-fpm amd64 7.4.3-4ubuntu2.10 [1,434 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 php-fpm all 2:7.4+75 [2,792 B]
Fetched 1,436 kB in 1s (1,937 kB/s)
Selecting previously unselected package php7.4-fpm.
(Reading database ... 122098 files and directories currently installed.)
Preparing to unpack .../php7.4-fpm_7.4.3-4ubuntu2.10_amd64.deb ...
Unpacking php7.4-fpm (7.4.3-4ubuntu2.10) ...
Selecting previously unselected package php-fpm.
Preparing to unpack .../php-fpm_2%3a7.4+75_all.deb ...
Unpacking php-fpm (2:7.4+75) ...
Setting up php7.4-fpm (7.4.3-4ubuntu2.10) ...
Creating config file /etc/php/7.4/fpm/php.ini with new version
NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Created symlink /etc/systemd/system/multi-user.target.wants/php7.4-fpm.service → /lib/systemd/system/php7.4-fpm.service.
Setting up php-fpm (2:7.4+75) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.15) ...
Processing triggers for php7.4-fpm (7.4.3-4ubuntu2.10) ...
NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
安装成功, 按提示重启对应服务
root@instance-220331152519:/etc/apache2# a2enmod proxy_fcgi setenvif
Considering dependency proxy for proxy_fcgi:
Enabling module proxy.
Enabling module proxy_fcgi.
Module setenvif already enabled
To activate the new configuration, you need to run:
systemctl restart apache2
root@instance-220331152519:/etc/apache2# systemctl restart apache2
root@instance-220331152519:/etc/apache2# a2enconf php7.4-fpm
Enabling conf php7.4-fpm.
To activate the new configuration, you need to run:
systemctl reload apache2
root@instance-220331152519:/etc/apache2# systemctl reload apache2
6) 刷新页面,问题修复
phpinfo 以及 wordpress页面都成功显示。