linux 下 nginx 二级目录中访问Laravel项目

    网上有很多相关的文档了,但我在配置自己的服务器的时候,却总是访问不成功。各种偿试后访问成功,其实也就那么简单的配置,以此做记录。

环境:centos7.4 + nginx 1.12.2 + php 7.2 + Laravel 5.6

主目录:/data

php_gift_platform里面是从git签出的laravel项目代码。

htdocs目录中做了一个链接到laravel项目的public目录

修改 nginx.conf,增加路由:

location /gift_platform {
                root /data/htdocs/gift_platform;
                index  index.php index.html index.htm;
                try_files $uri $uri/ /gift_platform/index.php?$query_string;
                if (!-e $request_filename){  
                    rewrite  ^/gift_platform/(.*)$  /gift_platform/index.php?s=$1  last;  
                }
        }

猜你喜欢

转载自blog.csdn.net/qdslp/article/details/89010834