php7-nginx-composer 安装laravel

修改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!就到这了哦,有问题,可留言,一并讨论。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值