您的位置:首页 > 编程语言 > PHP开发

lnmp一键安装包对laravel项目的部署配置哦

2016-12-15 10:48 633 查看
前言:

   接触lnmp一键安装包,的确好用,但是我在配置laravel项目的时候,遇到了一些麻烦

问题:

   直接使用lnmp配置了下vhost下的虚拟机目录后,配置的是public目录下,直接访问laravel项目的时候,会出现如下错误:nginx   不能访问或者  not  found

解决:

  上网找了下,原来是要配置下优雅链接:

    location / {

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

                  }

问题:现在laravel项目是可以访问了,但是js,css,图片的一些资源文件不能访问加载,又去找了找,原来http://www.story.com/public/default/css/font-awesome.min.css 

   多了一个public目录,把它去掉就可以访问资源了

  原来代码中也多了个  /public/default/css/........

@section('css')
<link rel="stylesheet" href="/public/default/css/iCheck/square/blue.css">
@endsection


解决:

 location /public{

             root  $prj_root;

           }

遇到  /public  的url访问时候,直接跳转到项目的根目录下面,而不是public 目录下面

最后:

  就可以访问资源文件了哦!

粘贴下nginx的配置:

 server

    {

        listen 80;

        #listen [::]:80;

        server_name www.story.com;

        index index.html index.htm index.php default.html default.htm default.php;

        set $app_root /var/story/public;

        set $prj_root /var/story;

        root $app_root;

        include index.php.conf;

        #error_page   404   /404.html;

        include enable-php.conf;

    location /public{

             root  $prj_root;

        }

    location / {

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

                  }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

        {

           #expires      30d;

           root $prj_root;

        }

   location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {

            root /var/story;   #可以注释掉

        }

  location ~ \.php {

            fastcgi_pass 127.0.0.1:9000;

            fastcgi_index /index.php;

            fastcgi_split_path_info       ^(.+\.php)(/.+)$;

            fastcgi_param PATH_INFO       $fastcgi_path_info;

            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

            include                       fastcgi_params;

        }

     #     location ~ .*\.(js|css)?$

     #    {

     #       expires      12h;

     #  }

        location ~ /\.

        {

            deny all;

        }

        access_log  /home/wwwlogs/story.log.log;

    }


最后提醒下:

  如果

<link rel="stylesheet" href="/public/default/css/iCheck/square/blue.css">

连接的路径没有  /public  的话,可以

location /public{

             root  $prj_root;

        }

注释删除掉
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: