lnmp1.4 安装 laravel5.4 的 nginx 配置文件

  • 首先移除很坑的防跨目录功能
    LNMP 1.4上如果不想用防跨目录还需要将 /usr/local/nginx/conf/fastcgi.conf 里面的
    fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";删除
    LNMP 1.4上也可以直接使用lnmp1.4/tools/ 目录下的 ./remove_open_basedir_restriction.sh 进行移除。

LNMP1.4自带的这个工具会删除网站目录的.user.ini和nginx的fastcgi.conf里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

  • 重启nginx。

  • 编辑站点的nginx配置文件 将xxxxx.cn换成你的域名
    vim /usr/local/nginx/conf/vhost/xxxxx.cn.conf

  • 将下面的配置文件贴进去

server
    {   
        listen 80;
        #listen [::]:80;

        # server_name 换成你的域名 
        server_name xxxxx.cn ;

        index index.html index.htm index.php default.html default.htm default.php;
        
        # xxxxx.cn 换成你的域名
        root  /home/wwwroot/xxxxx.cn/public;

        # laravel 文档给的nginx配置
        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        include fastcgi.conf;
        #error_page   404   /404.html;
        include enable-php.conf;



        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {   
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {   
            expires      12h;
        }
        location ~ /\.
        {   
            deny all;
        }
        access_log  /home/wwwlogs/info.log;
}
  • 重启nginx
    /etc/init.d/nginx restart
  • 完成
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容