当我输入我的域名时我得到:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.29 (Ubuntu) Server at www.mywebsite.net Port 443
在我的错误日志中我发现了这一点:
/var/www/html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: https://www.google.lv/
我的 PHP 版本运行 php -v
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
我的 .htaccess 中有这个
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^165\.227\.175\.218$
RewriteRule ^(.*)$ http://www.mywebsite.net/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Wordfence WAF
<IfModule mod_php7.c>
php_value auto_prepend_file '/var/www/html/mywebsite/public_html/wordfence-waf.php'
在 /var/www/html/mywebsite/public_html/wordfence-waf.php 中我有这个:
<?php
// Before removing this file, please verify the PHP ini setting `auto_prepend_file` does not point to this.
if (file_exists('/var/www/html/mywebsite/public_html/wp-content/plugins /wordfence/waf/bootstrap.php')) {
define("WFWAF_LOG_PATH", '/var/www/html/mywebsite/public_html/wp-content /wflogs/');
include_once '/var/www/html/mywebsite/public_html/wp-content/plugins/wordfence/waf/bootstrap.php';
}
?>
我试过:
sudo a2enmod rewrite && sudo service apache2 restart
/etc/host.conf: line 3: bad command `nospoof on'
Module rewrite already enabled
/etc/host.conf: line 3: bad command `nospoof on'
/usr/sbin/apache2 -V | grep MPM
[Tue Jan 08 12:05:13.506757 2019] [core:warn] [pid 6361] AH00111: Config variabl e ${APACHE_LOCK_DIR} is not defined
[Tue Jan 08 12:05:13.506990 2019] [core:warn] [pid 6361] AH00111: Config variabl e ${APACHE_PID_FILE} is not defined
[Tue Jan 08 12:05:13.507254 2019] [core:warn] [pid 6361] AH00111: Config variabl e ${APACHE_RUN_USER} is not defined
[Tue Jan 08 12:05:13.507358 2019] [core:warn] [pid 6361] AH00111: Config variabl e ${APACHE_RUN_GROUP} is not defined
[Tue Jan 08 12:05:13.507469 2019] [core:warn] [pid 6361] AH00111: Config variabl e ${APACHE_LOG_DIR} is not defined
[Tue Jan 08 12:05:13.514596 2019] [core:warn] [pid 6361] AH00111: Config variabl e ${APACHE_RUN_DIR} is not defined
[Tue Jan 08 12:05:13.515068 2019] [core:warn] [pid 6361] AH00111: Config variabl e ${APACHE_LOG_DIR} is not defined
Server MPM: prefork
尝试看看这链接可以帮助我。
我运行:sudo apachectl -t
并得到syntax ok
。我无法运行,sudo apache2 -X -f /etc/apache2/httpd.conf
因为我没有httpd.conf
文件。如果我运行:service apachectl start
我得到Failed to start apachectl.service: Unit apachectl.service not found.
这是我的/etc/apache2/envvars
# envvars - default environment variables for apache2ctl
# this won't be correct after changing uid
unset HOME
# for supporting multiple apache2 instances
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
SUFFIX=
fi
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
# temporary state file location. This might be changed to /run in Wheezy 1
export APACHE_PID_FILE=/var/run/apache2$SUFFIX/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale
export LANG
## The command to get the status for 'apache2ctl status'.
## Some packages providing 'www-browser' need '--dump' instead of '-dump'.
#export APACHE_LYNX='www-browser -dump'
## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'
## If you would like to pass arguments to the web server, add them below
## to the APACHE_ARGUMENTS environment.
#export APACHE_ARGUMENTS=''
## Enable the debug mode for maintainer scripts.
## This will produce a verbose output on package installations of web server modules and web application
## installations which interact with Apache
#export APACHE2_MAINTSCRIPT_DEBUG=1
任何有关如何再次访问我的网站的帮助都将不胜感激。我可以通过 WinSCP 和 Putty 进行 SSH 访问。
答案1
升级到 18.04 会导致 PHP 模块被禁用。对我来说,运行以下命令可以解决问题:
sudo a2enmod php7.2
systemctl restart apache2