原文鏈接: 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/<your-project>/public;
index index.php index.html index.htm;
server_name <your domain or IP>;
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/<your-project>/storage