【发布时间】:2017-07-15 13:41:35
【问题描述】:
假设我的路径如下:
/var/www/myside/
该路径包含两个文件夹...假设
/static 和 /manage
我想配置 nginx 以访问:
/static/ 上的文件夹(例如,http://example.org/)
这个文件夹有一些 .html 文件。
/manage 上的/manage 文件夹(例如http://example.org/manage)在这种情况下,此文件夹包含 Slim 的 PHP 框架代码 - 这意味着 index.php 文件位于 public 子文件夹中(例如 /var/www/ mysite/manage/public/index.php)
我试过很多组合比如
server {
listen 80;
server_name example.org;
error_log /usr/local/etc/nginx/logs/mysite/error.log;
access_log /usr/local/etc/nginx/logs/mysite/access.log;
root /var/www/mysite;
location /manage {
root $uri/manage/public;
try_files $uri /index.php$is_args$args;
}
location / {
root $uri/static/;
index index.html;
}
location ~ \.php {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
}
/ 无论如何都可以正常工作,manage 不能。难道我做错了什么?有人知道我应该改变什么吗?
马修。
【问题讨论】:
-
我认为
root $uri/(directory);行不通,不是吗?这肯定会有些奇怪,比如root /manage/manage/public,而不是你想要的。还是我误解了$uri的作用? -
@Bytewave 是的,你说得对,它不会起作用。这是我已经尝试过的百万种组合之一:) 让我们假设没有 $uri 但
/var/www/mysite/manage/public和/var/www/mysite/static- 无论如何它不起作用。
标签: php http nginx server slim