【发布时间】:2018-12-03 01:09:18
【问题描述】:
我还不习惯 Nginx...从 Apache2 迁移。我不明白 location 和 root 指令...我读过 root 最好在别名上使用...所以,我将所有的 root 设置为绝对路径。
这里的服务器块:
index index.php index.html;
location = / {
root /var/www/app;
}
location /chat/ {
root /var/www/project1/chat;
}
location /kanban/ {
root /var/www/kanban;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include fastcgi_params;
}
当我有 root /var/www/app;在位置块之外,主要的 index.php 将起作用。但是,当使用根路径添加位置块时,我得到的只是 404 页。我希望不需要为每个定义的位置添加 PHP 位置块,这肯定不需要吧?
我只想让 www.site.com 转到 /var/www/app/index.php 和 www.site.com/chat/ 转到 /var/www/project1/chat/index。我的每个项目的 php 等。
【问题讨论】:
标签: nginx