首先我将grav安装到nginx服务器的子级目录,它运行正常:cadoankitovua.com/blog
conf文件:
server {
listen 80;
server_name cadoankitovua.com www.cadoankitovua.com *.cadoankitovua.com;
root /home/grav/web/public/;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php?_url=$uri&$query_string;
}
location ~ \.php$ {
include /opt/local/etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
然后,我在/ text目录中安装了一个相同的grav副本,并尝试以我所知的许多不同方式修改conf文件。没有用。
我有两个问题:
如何编辑conf文件以在/ blog和/ text目录上进行grav工作?
一般情况下,如果我将它们安装在许多子级目录中,如何安装很多(> 2)grav工作?
提前致谢。
答案 0 :(得分:1)
我对grav一无所知,但您可以先添加location /text
块:
server {
listen 80;
server_name cadoankitovua.com www.cadoankitovua.com *.cadoankitovua.com;
root /home/grav/web/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /blog/index.php?_url=$uri&$query_string;
}
location /text {
try_files $uri $uri/ /text/index.php?_url=$uri&$query_string;
}
location ~ \.php$ {
include /opt/local/etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
编辑:一般解决方案将使用带有重写语句的命名位置,例如:
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^(/[^/]+) $1/index.php?_url=$uri&$query_string last;
rewrite ^ /blog/index.php?_url=$uri&$query_string last;
}