Ubuntu18.10安装Laravel

#0 nginx

配置信息在

cd /etc/nginx/
sudo vim nginx.conf

cd /etc/nginx/sites-available
sudo vim default 

#重启nginx
sudo systemctl restart nginx
复制代码
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/top/public;

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";

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

        server_name locoroco;

        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;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        error_page 404 /index.php;
        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
        #
        #       # With php-fpm (or other unix sockets):
        #       fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                #fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
                fastcgi_pass 127.0.0.1:9000;
                #fastcgi_index index.php;
                include snippets/fastcgi-php.conf;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
        location ~ /\.(?!well-known).* {
                deny all;
        }
}

复制代码

#1 安装php7.2及相关组件

  • 安装php7.2-zip
#install zip
sudo apt-get install php7.2-zip -y
#restart php
sudo systemctl restart php7.2-fpm

### more action
systemctl restart php7.2-fpm #重启
systemctl start php7.2-fpm #启动
systemctl stop php7.2-fpm #关闭
systemctl status php7.2-fpm #检查状态
###


#查看可用模块
php -m
复制代码

参考 在 Ubuntu/Debian 下安装 PHP7.2

2# 安装composer

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php
sudo php -r "unlink('composer-setup.php');"

#之前只是当前目录可用,拷贝到全局
sudo mv composer.phar /usr/local/bin/composer

#改为Laravel-china镜像
sudo composer config -g repo.packagist composer https://packagist.laravel-china.org
复制代码

3# phpstorm配置

安装后启动链接在/usr/local/bin/phpstorm

#新增组
sudo groupadd www-pub
#将自己[locoroco]加入该组
sudo usermod -a -G www-pub locoroco

###
#查看用户加入的组
sudo groups locoroco
#locoroco : locoroco adm cdrom sudo dip plugdev lpadmin sambashare www-pub
###

#修改/var/www 下的的权限Change the ownership of everything under /var/www to root:www-pub
sudo chown -R root:www-pub /var/www/

#自己加的
sudo usermod -a -G www-pub www-data

#Change the permissions of all the folders to 2775
#chmod 2775 /var/www ## 2=set group id, 7=rwx for owner (root), 7=rwx for group (www-pub), 5=rx for world (including apache www-data user)
#Set group ID (SETGID) bit (2) causes the group (www-pub) to be copied to all new files/folders created in that folder. Other options are SETUID (4) to copy the user id, and STICKY (1) which I think lets only the owner delete files.
#There's a -R recursive option, but that won't discriminate between files and folders, so you have to use find, like so:
sudo find -type d -exec chmod 2775 {} +

#Change all the files to 0664
sudo find /var/www -type f -exec chmod 0664 {} +

#Change the umask for your users to 0002
#查看当前用户umask
umask
#默认是0022

#临时设置:重启后就失效了
umask 0002
#永久设置
sudo vim ~/.profile

#reboot 重启让权限生效
复制代码

4#修改host文件

sudo vim /etc/hosts
复制代码

5#Laravel目录权限

cd /var/www/top
sudo chmod -R 777 storage
sudo chmod -R 777 bootstrap/cache
复制代码

6#解决 Laravel/Lumen 出现 "Please provide a valid cache path" 问题

storage下面的文件夹缺失,新建

mkdir -p storage/framework/views
mkdir -p storage/framework/cache
mkdir -p storage/framework/sessions
复制代码

注意这些目录要有读写权限.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值