laravel 的lnmp 的配置

装了lnmp后,一般用 lnmp vhost add 添加网站 一般 只用重写和ssl功能

再发laravel官方的配置

server {
listen 80;
server_name example.com;
root /example.com/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.html index.htm index.php;

charset utf-8;

#下面这句是lnmp自带的重写

#include rewrite/laravel.conf;

#下面这段是官方的,两个都可以用,二选一 

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

error_page 404 /index.php;

#官方的用 include enable-php-pathinfo.conf;的设置貌似容易出错,所以下面这个

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

#有些lnmp版本,只有一个php版本的,用下面这句,不要用上面那句!去掉#即使用,上面那句加上#

#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi_params;
}

location ~ /\.(?!well-known).* {
deny all;
}
}

posted @ 2019-05-04 21:53  火鸟网络  阅读(621)  评论(0编辑  收藏  举报