server {
listen 80;
root /var/www/laravel/public; #访问文件目录
index index.php index.html index.htm index.nginx-debian.html;
server_name lnmp.com; #将server_domain_or_IP修改为你的公网IP或者域名
location / {
try_files $uri $uri/ /index.php?$query_string; #laravel项目,路由设置
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
#确认php7.0-fpm.sock的位置,错误将无法正确识别php代码
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
|