WordPress 不执行 PHP 文件

WordPress 不执行 PHP 文件

我的 WordPress 主页显示:

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

我的平台:Ubuntu 16.04我正在使用阿帕奇.我该如何解决这个问题?

apache2 -M | grep php输出:

[Mon Nov 13 06:58:35.785748 2017] [core:warn] [pid 20486] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Mon Nov 13 06:58:35.785929 2017] [core:warn] [pid 20486] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Mon Nov 13 06:58:35.786020 2017] [core:warn] [pid 20486] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Mon Nov 13 06:58:35.786087 2017] [core:warn] [pid 20486] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Mon Nov 13 06:58:35.786164 2017] [core:warn] [pid 20486] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Nov 13 06:58:35.790530 2017] [core:warn] [pid 20486:tid 140021226223488] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Nov 13 06:58:35.790931 2017] [core:warn] [pid 20486:tid 140021226223488] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Nov 13 06:58:35.791163 2017] [core:warn] [pid 20486:tid 140021226223488] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

sudo dpkg --get-selections | grep php输出:

libapache2-mod-php              install
libapache2-mod-php7.0               install
php                     install
php-common                  install
php-curl                    install
php-gd                      install
php-gettext                 install
php-mbstring                    install
php-mcrypt                  install
php-mysql                   install
php-pear                    install
php-phpseclib                   install
php-tcpdf                   install
php-xml                     install
php-xmlrpc                  install
php7.0                      install
php7.0-cli                  install
php7.0-common                   install
php7.0-curl                 install
php7.0-gd                   install
php7.0-json                 install
php7.0-mbstring                 install
php7.0-mcrypt                   install
php7.0-mysql                    install
php7.0-opcache                  install
php7.0-readline                 install
php7.0-xml                  install
php7.0-xmlrpc                   install
phpmyadmin                  install

systemctl 状态 apache2.service输出:

* apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           `-apache2-systemd.conf
   Active: failed (Result: exit-code) since Mon 2017-11-13 07:12:52 EST; 5min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 20848 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 19096 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
  Process: 20898 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)

Nov 13 07:12:52 student apache2[20898]:  * The apache2 configtest failed.
Nov 13 07:12:52 student apache2[20898]: Output of config test was:
Nov 13 07:12:52 student apache2[20898]: [Mon Nov 13 07:12:51.996158 2017] [:crit] [pid 20909:tid 139772608190336] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need
Nov 13 07:12:52 student apache2[20898]: AH00013: Pre-configuration failed
Nov 13 07:12:52 student apache2[20898]: Action 'configtest' failed.
Nov 13 07:12:52 student apache2[20898]: The Apache error log may have more information.
Nov 13 07:12:52 student systemd[1]: apache2.service: Control process exited, code=exited status=1
Nov 13 07:12:52 student systemd[1]: Failed to start LSB: Apache2 web server.
Nov 13 07:12:52 student systemd[1]: apache2.service: Unit entered failed state.
Nov 13 07:12:52 student systemd[1]: apache2.service: Failed with result 'exit-code'.

答案1

您必须安装带有 Apache 配置的 php 模块。尝试以下命令安装相同的模块

sudo apt-get install php7.0 libapache2-mod-php7.0

然后使用以下命令重新启动 apache

sudo service apache2 restart

请注意,您的 php 版本可能会根据您的 Ubuntu 发行版而改变。

更新 :

根据日志看来您已将默认 MPM 更改为工人在 apache 配置中,php 模块不支持线程 MPM。因此,您必须使用 php_fpm 或 mod_fcgid 以线程 MPM 执行 php,否则请切换 apache 以使用预分叉最大行程长度。

您可以在这里获得安装 php-fpm 的分步详细信息 https://www.howtoforge.com/tutorial/apache-with-php-fpm-on-ubuntu-16-04/

相关内容