您的位置:首页 > 运维架构 > Nginx

php7-nginx-composer 安装laravel

2017-01-11 01:05 507 查看

修改nginx配置文件

本系统php版本是php7.0的,这是我的环境哈,我们主要看nginx配置文件即我的路径为/etc/nginx/site-avilable/default,将default参考下面的内容进行修改即可

root /var/www/html/laravel/public;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;

server_name localhost;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


对上面location ~ .php${}里的内容解释一下,fastcgi_pass 有2种配置,一种是TCP即是127.0.0.1:9000,一种是socket即是uninx:/run/php/php7.0-fpm.sock,php7.0默认是socket,我用的是socket的,2种方式都行;

如果你选择TCP的话,修改php配置文件,即路径为/etc/php/7.0/fpm/pool.d/www.conf,找到

listen = 127.0.0.1:9000


如果是socket的话,修改/etc/php/7.0/pool.d/www.conf

listen = /run/php/php7.0-fpm.sock


安装composer

# 下载composer
curl -sS https://getcomposer.org/installer | php
# 设置全局命令
mv composer.phar /usr/local/bin/composer


安装laravel

composer create-project laravel/laravel quickstart --prefer-dist


更改laravel所属组和拥有者

chown -R www-data:www-data /var/www/html/laravel


上面这一步很重要,如果不给的话,可能就无法访问,因为nginx用户是www-data

最后给storage权限

ok!就到这了哦,有问题,可留言,一并讨论。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  laravel5-2 composer