如何在 Linux VPS 上修复 WordPress 中的 HTTP 错误,修复在上传图像时出现的 HTTP 错误;修复因为不恰当的文件权限而产生的 HTTP 错误; 修复因为内存不足而产生的 HTTP 错误;修复因为 php.ini 文件错误配置而产生的 HTTP 错误...
1、 修复在上传图像时出现的 HTTP 错误
php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
vi /etc/php.ini
upload_max_filesize = 64M
post_max_size = 32M
max_execution_time = 300
max_input_time 300
memory_limit = 128M
vi /www/html/path_to_wordpress/.htaccess
php_value upload_max_filesize 64M
php_value post_max_size 32M
php_value max_execution_time 180
php_value max_input_time 180
# 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
server {
listen 80;
client_max_body_size 128m;
client_body_timeout 300;
server_name your-domain.com www.your-domain.com;
root /var/www/html/wordpress;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
2、 修复因为不恰当的文件权限而产生的 HTTP 错误
chown www-data:www-data -R /var/www/html/path_to_wordpress/
3、 修复因为内存不足而产生的 HTTP 错误
define('WP_MEMORY_LIMIT', '128MB');
4、 修复因为 php.ini 文件错误配置而产生的 HTTP 错误
vi /etc/php.ini
cgi.fix_pathinfo=0
date.timezone = Asia/Shanghai
5、 修复因为 Apache mod_security 模块而产生的 HTTP 错误
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
6、 修复因为有问题的插件/主题而产生的 HTTP 错误
mv /www/html/path_to_wordpress/wp-content/plugins /www/html/path_to_wordpress/wp-content/plugins.old