我对我的 nginx 配置感到沮丧,所以我要求帮助编写我的配置文件,以从同一根目录的子目录中提供多个项目。这不是虚拟主机,因为它们都使用相同的主机值。也许一个例子可以澄清我的尝试:
192.168.1.1/应当成为index.php从/var/www/public/192.168.1.1/wiki/应当成为index.php从/var/www/wiki/public/192.168.1.1/blog/应当成为index.php从/var/www/blog/public/这些项目使用 PHP 并使用 fastcgi。
我目前的配置非常小。
server {
listen 80 default;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
root /var/www;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
我已经试过各种事情alias和rewrite,但没能得到的东西正确的FastCGI的设置。这似乎应该有比写位置的块,复制更雄辩的方式root,index,SCRIPT_FILENAME,等。
任何让我朝着正确方向前进的指针都表示赞赏。