Nginx的使用(二)Nginx配置wordpress

安装php:https://windows.php.net/download/,php默认启动命令:php-cgi.exe -b 127.0.0.1:9000php

安装wordpress:https://cn.wordpress.org/html

原来wordpress是部署在iis中,安装了nginx之后,实际上能够直接经过nginx配置好php,而再也不经过iis:nginx

server {
        listen       80;
        server_name  help.adomain.cn;
location ~ \.php$ {
      root           E:/ServerCore/wordpress;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
}
}
E:/ServerCore/wordpress是wordpress的安装目录
127.0.0.1:9000是php-cgi.exe监听的9000端口,须要在启动php-cgi.exe时配置,nginx和php的启动参考:Nginx的使用(三)把nginx和php-cgi.exe注册成windows服务

wordpress官方的伪静态是经过.htaccess实现的,但nginx并不支持.htaccess,网上找到wordpress伪静态的方法:sql

  location / {
            root   E:/ServerCore/wordpress;
            index  index.php;
        if (-f $request_filename/index.html){
               rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php){
               rewrite (.*) $1/index.php;
         }
        if (!-f $request_filename){
               rewrite (.*) /index.php;
         }
    }

伪静态后页面什么的确实能够访问了,结果却出现新的问题,后台不能访问了,仔细观察发现后台全部地址都缺乏wp-admin目录,又在网上去寻找答案,就是简单地加一行斜杠重定向而已,方法以下:数据库

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

 wordpress域名修改之后,能够经过如下的sql语句修改wordpress数据库实现数据升级:windows

UPDATE wp_options SET option_value = replace( option_value, 'http://www.old.com', 'http://www.new.com' ) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace( post_content, 'http://www.old.com', 'http://www.new.com' ) ;
UPDATE wp_posts SET guid = replace( guid, 'http://www.old.com', 'http://www.new.com' ) ;
相关文章
相关标签/搜索