WordPress切换到Nginx服务器教程

二叶草 2020年2月21日19:33:10问题及解决评论阅读模式

这几天将几个WordPress的Web服务器从Apache切换到了Nginx,中间遇到了不少问题,因此记录一下,以便日后维护使用。

对于WordPress站点来说,固定链接主要是通过根目录下的.htaccess文件来控制,切换服务器后,Nginx的rewrite格式和Apache的不同,需要修改。

WordPress切换到Nginx服务器教程

先卸载Apache系统,之后安装Nginx系统。

在BT面板后台,点“网站”-“设置”-“伪静态”,对于单站点的WordPress来说,原先的.htaccess文件内容如下:

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

切换到Nginx系统后,其配置内容如下:

location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

对于子域名方式的多站点的WordPress来说,原先的.htaccess文件内容如下:

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]

切换到Nginx系统后,其配置内容如下:

if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*.php)$ $1 last;
rewrite ^ /index.php last;
}

此外,服务器上还安装了v2ray,原先在Apache里配置的内容如下:

RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /test/(.*)           ws://127.0.0.1:11111/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /test/(.*)           http://127.0.0.1:11111/$1 [P,L]

切换到Nginx后,在Nginx服务器配置文件里修改的内容如下:

location /test/ {
proxy_pass http://127.0.0.1:11111/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}

本文来源于:WordPress切换到Nginx服务器教程-变化吧门户
特别声明:以上文章内容仅代表作者本人观点,不代表变化吧门户观点或立场。如有关于作品内容、版权或其它问题请于作品发表后的30日内与变化吧联系。

  • 赞助本站
  • 微信扫一扫
  • weinxin
  • 加入Q群
  • QQ扫一扫
  • weinxin
二叶草
Wpscan使用教程-Wordpress网站渗透 问题及解决

Wpscan使用教程-Wordpress网站渗透

Wpscan是专门检查Wordpress网站漏洞的工具,它可以全面检查wp网站的漏洞,有助于我们增加网站安全防护。但是也有人使用Wpscan渗透别人的网站,最近我客户的网站就被黑了,现在简单把使用wp...

发表评论