美文网首页
使用phpStudy搭建Laravel开发环境 nginx配置

使用phpStudy搭建Laravel开发环境 nginx配置

作者: empyy | 来源:发表于2020-03-11 22:18 被阅读0次

    Laravel作为单一入口的PHP框架,路由是需要web服务重定向,本人一般使用nginx搭建web服务。
    nginx配置

    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;
    
        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;
    
        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            include fastcgi_params;
        }
    
        location ~ /\.(?!well-known).* {
            deny all;
        }
    }
    
    

    所以在配置文件加入

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

    而phpStudy每次重启,都会重置nginx配置,干脆就在错误页面加入

     try_files $uri $uri/ /index.php?$query_string;
    
    image.png

    相关文章

      网友评论

          本文标题:使用phpStudy搭建Laravel开发环境 nginx配置

          本文链接:https://www.haomeiwen.com/subject/ifdkjhtx.html