Laravel 部署

原文链接: https://laravel-china.org/articles/8983/laravel-deploys-to-the-ali-cloud-tencent-cloud

语言包安装

sudo apt-get install -y language-pack-en-base
locale-gen en_US.UTF-8

常用软件

sudo apt-get install -y vim git zip unzip

安装 Nginx

sudo apt-get update
sudo apt-get install nginx
//如果安装了 apache2 ,需要先卸载
sudo service apache2 stop
sudo apt-get --purge remove apache2
sudo apt-get --purge remove apache2.2-common
sudo apt-get autoremove

安装 PHP 7

sudo apt-get install -y software-properties-common

sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

sudo apt-get update

apt-cache search php7.1

sudo apt-get install -y php7.1

sudo apt-get install -y php7.1-mysql

sudo apt-get install -y php7.1-fpm

sudo apt-get install -y php7.1-curl php7.1-xml php7.1-mcrypt php7.1-json php7.1-gd php7.1-mbstring

安装 MySQL
sudo apt-get install -y mysql-server

文件配置

sudo vim /etc/php/7.1/fpm/php.ini
set cgi.fix_pathinfo=0
sudo vim /etc/php/7.1/fpm/pool.d/www.conf
set listen = /var/run/php7.1-fpm.sock
sudo vim /etc/nginx/sites-available/default
>replace with below<
"
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www//public;

    index index.php index.html index.htm;

    server_name ;

    location / {
        try_files $uri $uri/ /index.php?$query_string;      
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php7.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
"

composer安装

install guide
try:
php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Redis

  • 安装
sudo apt-get update
sudo apt-get install redis-server
  • 启动
    redis-server
  • 查看是否启动
    redis-cli

Project

  • install dependency
    composer install
  • config environment
    cp .env.example .env
  • generate appkey
    php artisan key:generate
  • database
    php artisan migrate
  • auth
    sudo chown -R www-data:www-data /var/www
    sudo chmod -R 777 /var/www//storage

你可能感兴趣的:(Laravel 部署)