nginx配置从位置具有不同的根

时间:2018-05-07 09:07:16

标签: nginx configuration

我尝试配置nginx,以便通过不同的URL拥有不同的项目。 让我解释。 您访问http://localhost/test1并且nginx要求PHP处理/var/www/test-1/index.php中的文件 您访问http://localhost/test2并且nginx要求PHP处理/var/www/test-2/index.php

中的文件

问题是:我只有404错误。这是我的nginx配置:

server {
listen 80;
listen [::]:80;
root /var/www;
index  index.php index.html index.htm;
server_name  192.168.15.92;

location /test1 {
    alias /var/www/test-2;
}

location /test2 {
    alias /var/www/test-2;
}


location ~ \.php$ {
       include snippets/fastcgi-php.conf;
#       # With php-fpm (or other unix sockets):
       fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}

我正在运行debian 9。

希望有人可以帮助我:)。

0 个答案:

没有答案
相关问题