Home>Article>PHP Framework> Laravel environment setup: steps on how to deploy laravel to Alibaba Cloud or Tencent Cloud
Many laravel beginners don’t know how to deploy the laravel framework on Alibaba Cloud? There are also many students using Tencent Cloud. Today, PHP Chinese website will explain in detail how to build laravel environment and deploy laravel to Alibaba Cloud and Tencent Cloud. The following is the deployment of laravel to Alibaba Cloud or Tencent Cloud. specific steps above.
PS: I don’t need to teach you how to buy an Alibaba Cloud/Tencent Cloud server Alright~~
Select ubuntu 16.04 for the installation system
Then log in to the remote server through ssh and follow the following steps to configure:
Step 2: Update List
apt-get updateStep 3: Install language pack
sudo apt-get install -y language-pack-en-base locale-gen en_US.UTF-8Step 4: Install common software
sudo apt-get install -y vim git zip unzipStep 5: Install PHP7
Please make sure there are no errors in each step. If there are errors, you can try to install it a few more 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-mbstringStep 6: Install Mysql
sudo apt-get install -y mysql-serverNote: You need to set a password after installation
##Step 7 :Install Nginx
Before installation, you need to confirm whether apache2 is installed. If apache2 is already installed, you need to stop/uninstall apache2
//安装之前需确认是否安装了apache2,如果已经安装了apache2,需要先停止/卸载 apache2 sudo service apache2 stop //安装 nginx sudo apt-get install -y nginx
sudo vim /etc/php/7.1/fpm/php.ini //修改 cgi.fix_pathinfo=0 sudo vim /etc/php/7.1/fpm/pool.d/www.conf //修改 listen = /var/run/php7.1-fpm.sockPart 9: Configure Nginx
sudo vim /etc/nginx/sites-available/default //修改如下,根据自己的项目情况修改对应信息:'laravel-project'替换为你的项目,'server_domain_or_IP' 替换为你的网站域名或IP地址 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; } }Step 10: Pull the code
It is recommended to upload the code to the cloud code warehouse (github, coding) first and then pull it on the server
cd /var/www git clone 地址
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');" //然后移动 composer.phar mv composer.phar /usr/local/bin/composer //进入项目目录 cd /var/www/laravel-project //执行 composer install composer install
Step 11: Create the .env file
cd /var/www/laravel-project cp .env.example .env vim .envNote: Modify the .env file according to the actual situation of the project
Step 12: Generate laravel key
cd /var/www/laravel-project php artisan key:generateStep 13: Create database and perform migration
First log in to mysql to create a database corresponding to the project. The name should be consistent with the one in the .env file
cd /var/www/laravel-project php artisan migrate
sudo chown -R www-data:www-data /var/www sudo chmod -R 777 /var/www/laravel-project/storageStep 15: Restart Nginx and PHP7 fpm
service nginx restartservice php7.1-fpm restart 搞定!
Recommended:
Deploy Laravel project on Alibaba Cloud's ECS
## Use Alibaba Cloud OSS Composer package sharing in Laravel, laraveloss
The above is the detailed content of Laravel environment setup: steps on how to deploy laravel to Alibaba Cloud or Tencent Cloud. For more information, please follow other related articles on the PHP Chinese website!