nginx下配置laravel

2018-04-18  本文已影响0人  不留余白

安装composer

brew install composer

修改镜像

composer config -g repo.packagist composer https://packagist.phpcomposer.com

全局安装laravel

export PATH=$PATH:~/.composer/vendor/bin

苹果系统: $HOME/.composer/vendor/bin

GNU / Linux发行版: $HOME/.config/composer/vendor/bin

首先,通过 Composer 下载 Laravel 安装器。

composerglobalrequire"laravel/installer=~1.1"

laravelnewblog 将会在当前目录下创建一个叫 blog 的目录

Laravel框架有一个目录需要额外设置权限: 需要为 app/storage 目录下的文件设置写权限。

chmod -R 777 storage/

.nginx 配置文件

server {  
        listen  80;    
        server_name aa.com;    
        set $root_path '/code/laravelStudy/public';    
        root $root_path;    
        index index.php index.html index.htm;    
        try_files $uri $uri/ @rewrite;    
        location @rewrite {    
            rewrite ^/(.*)$ /index.php?_url=/$1;    
        }    
        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 ~* ^/(css|img|js|flv|swf|download)/(.+)$ {    
            root $root_path;    
        }    
        location ~ /\.ht {    
            deny all;    
        }    
    }
上一篇下一篇

猜你喜欢

热点阅读