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

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

原来wordpress是部署在iis中,安装了nginx以后,实际上可以直接通过nginx配置好php,而不再通过iis:

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伪静态的方法:

  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数据库实现数据升级:

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' ) ;

 

 

 

 

posted on 2018-12-07 15:22  二豆  阅读(6996)  评论(0编辑  收藏  举报