server { listen 80; listen [::]:80 ; root /vagrant/www/ubuntu/Laravel5/public; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name abc.com; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. #这里路由中过滤index.php写法 try_files $uri $uri/ /index.php?$query_string; # try_files $uri $uri/ =404; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php7.0-cgi alone: fastcgi_pass 127.0.0.1:9000; # # With php7.0-fpm: # fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }
注意事项:
1、#默认是没有添加index.php的,否则报403 forbidden 错误!
2、#需要在/etc/php/7.0/fpm/pool.d/www.conf做如下修改(否则报502 bad gateway )
# 修改完成后需要重启服务 :
service php7.2-fpm restart
Comments (0)