在我从 example2.com/blog 删除所有 WordPress 文件之前,它运行良好。现在,我尝试访问服务器上的每个页面和网站时都会收到错误 500。我在删除文件之前使用 CloudFlare 启用了 HTTPS,因此这可能是问题的一部分。Apache 错误和访问日志未显示任何错误。Fail2ban 未显示它正在禁止我的 IP。
这是我启用的唯一配置:
Listen 80
<VirtualHost *:80>
ServerName college.example1.com
ServerAlias college.example1.com
DocumentRoot /var/www/html/example1.com/college
<Directory "/var/www/html/example1.com/college">
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName dev.example1.com
ServerAlias dev.example1.com
DocumentRoot /var/www/html/example1.com/dev
<Directory "/var/www/html/example1.com/dev">
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName pma.example1.com
ServerAlias pma.example1.com
DocumentRoot /var/www/html/phpmyadmin
<Directory "/var/www/html/phpmyadmin">
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName example1.com
ServerAlias example1.com
DocumentRoot /var/www/html/example1.com/master
<Directory "/var/www/html/example1.com/master">
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName example2.com
ServerAlias example2.com
DocumentRoot /var/www/html/example2/master
<Directory "/var/www/html/example2/master">
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
Alias /blog /var/www/html/example2/blog
<Directory "/var/www/html/example2/blog">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName dev.example2.com
ServerAlias dev.example2.com
DocumentRoot /var/www/html/example2/dev
<Directory "/var/www/html/example2/dev">
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName dev.example4.example3.com
ServerAlias dev.example4.example3.com
DocumentRoot /var/www/html/apps/example4/dev
<Directory "/var/www/html/apps/example4/dev">
Require all granted
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName example4.example3.com
ServerAlias example4.example3.com
DocumentRoot /var/www/html/apps/example4/master
<Directory "/var/www/html/apps/example4/master">
Require all granted
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE US AllowCountry
Require env AllowCountry
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Apache 错误(调试)日志:
[Thu Nov 30 02:58:21.132058 2017] [authz_core:debug] [pid 6517] mod_authz_core.c(809): [client xxx.xxx.xxx.xx:21611] AH01626: authorization result of Require env AllowCountry: granted
[Thu Nov 30 02:58:21.132243 2017] [authz_core:debug] [pid 6517] mod_authz_core.c(809): [client xxx.xxx.xxx.xx:21611] AH01626: authorization result of <RequireAny>: granted
[Thu Nov 30 02:58:21.133029 2017] [authz_core:debug] [pid 6517] mod_authz_core.c(809): [client xxx.xxx.xxx.xx:21611] AH01626: authorization result of Require env AllowCountry: granted
[Thu Nov 30 02:58:21.133286 2017] [authz_core:debug] [pid 6517] mod_authz_core.c(809): [client xxx.xxx.xxx.xx:21611] AH01626: authorization result of <RequireAny>: granted
[Thu Nov 30 02:58:21.138691 2017] [:error] [pid 6517] [client xxx.xxx.xxx.xx:21611] PHP Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Thu Nov 30 02:58:21.138952 2017] [:error] [pid 6517] [client xxx.xxx.xxx.xx:21611] PHP Fatal error: Unknown: Failed opening required '/var/www/html/example2/blog/wordfence-waf.php' (include_path='.:/usr/share/php') in Unknown on line 0
答案1
我发现我在 php.ini 中auto_prepend_file
设置了wordfence-waf.php
,但错误日志中将其列为 PHP 无法访问。注释掉该行并重新加载 Apache 即可解决问题。