ErJ*_*Jab 14 php configuration nginx
我的主网站和wordpress在我的服务器上的不同目录中使用nginx作为Web服务器.主要网站位于/ home/me/www,Wordpress位于/ home/me/wordpress.出于特殊原因,我需要以这种方式将它们放在单独的目录中.如何在nginx配置文件中指定它?我目前有以下内容,但它不起作用:
location / {
root /home/me/www;
index index.php index.html index.htm;
}
location /blog {
root /home/me/wordpress;
index index.php index.html index.htm;
}
location ~ \.php$ {
set $php_root /home/me/www;
if ($request_uri ~ /blog) {
set $php_root /home/me/wordpress;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试访问http:// mydomain/blog时,它当前返回HTTP 404
Nic*_*sta 12
尝试将您的blog
行更改为:
location ^~ /blog/ {
root /home/me/wordpress;
index index.php index.html index.htm;
}
Run Code Online (Sandbox Code Playgroud)