Laravel deployed to Ali cloud / cloud Tencent
First you need a cloud Ali / Tencent cloud server
Installation system selection ubuntu 16.04
Then log in via ssh remote server configured as follows:
update list
apt-get update
to install language packs
sudo apt-get install -y language-pack-en-base
locale-gen en_US.UTF-8
install common software
sudo apt-get install -y vim git zip unzip
安装PHP7
// make sure that every step is not wrong, if there is an error, try to install more than a few times
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
// After installation you need to set a password
to install Nginx
// to be confirmed before the installation whether installed apache2, apache2 if already installed, you need to stop / unload apache2
// stop
sudo apache2 STOP Service
// unload
sudo APT-GET --purge the Remove apache2
sudo APT-GET --purge the Remove the Common-Apache2.2
sudo APT-GET autoremove
// install nginx
sudo apt-get install -y nginx
配置 PHP7
sudo vim /etc/php/7.1/fpm/php.ini
// modify cgi.fix_pathinfo = 0
sudo vim /etc/php/7.1/fpm/pool.d/www.conf
// modify listen = /var/run/php7.1-fpm.sock
configure Nginx
sudo vim /etc/nginx/sites-available/default
// modified as follows, modify the corresponding information in accordance with their own project situation: 'laravel-project' is replaced with your project, 'server_domain_or_IP' is replaced with your website domain name or IP address of the
Server {
the listen 80 default_server;
the listen [::]: 80 default_server;
root /var/www/laravel-project/public;
index index.php index.html index.htm;
server_name server_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;
}
}
Pulling Code
// the proposed first code is uploaded to the cloud code repository (github, coding) and then pull on the server
cd / var / www
git clone address
mounting Composer installation and use code depends Composer
Access composer's official website to obtain the latest version of the following four lines of code, paste it directly perform the installation Composer
php -r “copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’);”
php -r “if (hash_file(‘SHA384’, ‘composer-setup.php’) === ‘669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”
php composer-setup.php
php -r “unlink(‘composer-setup.php’);”
// then move composer.phar
mv composer.phar / usr / local / bin / Composer
// into the project directory
cd / var / www / laravel- project
// execute install Composer
Composer install
create .env file
cd / var / www / laravel-project
cp .env.example .env
vim .env
// modify .env files based on the actual situation of the project
to generate laravel key
cd / var / www / laravel-project
php artisan key: generate
create the database, perform the migration
// first log mysql database to create a corresponding item, the name should be in the same file .env
cd / var / www / laravel-project
php artisan migrate
to modify permissions
sudo chown -R www-data: www-data / var / www
sudo chmod -R 777 / var / www / laravel-project / storage
restart PHP7 fpm and Nginx
service nginx restart
service php7.1-fpm restart
to get!