我有个wordpress 站点,是用 lnmp环境搭建的。以前wordpress部署在根目录,直接用域名 www.xxxxx.com 能够访问。 先我想把这个wordpress移动到子目录中去,例如移动到根目录的mse_cn 文件夹下,然后访问通过www.xxxxx.com/mse_cn 首先我把代码都移到了mse_cn 文件夹下,然后修改了nginx的配置:
server {
listen 80;
server_name www.xxxx.com;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location ^~ /mse_cn {
root /usr/share/nginx/html;
index index.php index.html index.htm;
try_files $uri $uri/ /mse_cn/index.php;
location ~ \.php {
fastcgi_split_path_info ^(.*\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
重新加载nginx配置文件,然后我访问 www.xxxxx.com/mse_cn 报404错误,而且页面显示得很奇怪,请求高手帮助!!!
location ^~ /mse_cn {
是什么鬼?lnmp默认不应该是在/home/wwwroot这个目录中么?
www.xxxxx.com/mse_cn 要通过这种形式访问,只需要把wp移动到之前xxxxx.com的mse_cn目录中就可以了,nginx原有vhost.conf不用做任何修改