您现在的位置是:首页 > cms教程 > WordPress教程WordPress教程

Nginx配置wordpress的方法示例

尤政航2025-03-17 22:43:59WordPress教程已有3人查阅

导读安装php:https://windows.php.net/download/,php默认启动命令:php-cgi.exe -b 127.0.0.1:9000安装wordpress:https://cn.wordpress.org/原来wordpress是部署在iis中,安装了ngin

安装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:// .old.com', 'http:// .new.com' ) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace( post_content, 'http:// .old.com', 'http:// .new.com' ) ;
UPDATE wp_posts SET guid = replace( guid, 'http:// .old.com', 'http:// .new.com' ) ;

本文标签:

很赞哦! (1)

暂无内容
暂无内容
暂无内容
暂无内容
留言与评论 (共有 0 条评论)
昵称:
匿名发表 登录账号
         
验证码: