如何在Nginx上本地设置多个项目?
我想在nginx上本地设置多个项目 以下是我的两个服务器块:如何在Nginx上本地设置多个项目?,nginx,Nginx,我想在nginx上本地设置多个项目 以下是我的两个服务器块: server { listen 80; listen [::]:80; root /var/www/site1.dev/html; index index.php index.html index.htm; server_name site1.dev; location / { try_files $uri $uri/ =404; } locati
server {
listen 80;
listen [::]:80;
root /var/www/site1.dev/html;
index index.php index.html index.htm;
server_name site1.dev;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
}
ping site1.dev site2.dev将给出响应
在浏览器中,转到localhost将重定向到site1.dev
浏览site1.dev将重定向到并返回“无法访问此站点”
我错过什么了吗?根据TUT,这些块是正确的。您最好不要使用
dev
域。
server {
listen 80;
listen [::]:80;
root /var/www/site2.dev/html;
index index.php index.html index.htm;
server_name site2.dev;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}