centos下为laravel框架配置nginx服务器虚拟主机

来源:互联网 发布:javascript用什么打开 编辑:程序博客网 时间:2024/05/17 05:51

一般来说,nginx服务器配置虚拟主机很简单,

1. cd  /etc/nginx/conf.d

        2. cp default.conf    laravel.conf

3. 修改如下部分:

location / {        root   /usr/share/nginx/html/laravel/public;        index index.php  index.html index.htm;    }
location ~ \.php$ {        root           /usr/share/nginx/html/laravel/public;        fastcgi_pass   127.0.0.1:9000;        fastcgi_index  index.php;        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;        include        fastcgi_params;    }
4. 重启服务 

service nginx restart

但是,如果laravel框架首页登录使用第三方的路由,则会报404错误。所以,此时需要在上述第一部分增加如下一行代码:

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

0 0