search
HomePHP FrameworkLaravelLaravel 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.

Step one: You need an Alibaba Cloud/Tencent Cloud server

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 update

Step 3: Install language pack

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

Step 4: Install common software

sudo apt-get install -y vim git zip unzip

Step 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-mbstring

Step 6: Install Mysql

sudo apt-get install -y mysql-server
Note: 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

Step 8: Configure PHP7

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.sock
Part 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 地址

Install Composer and use Composer to install Code dependencies

Visit the composer official website to get the latest version of the following four lines of code, directly paste and execute to install 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');"
//然后移动 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 .env
Note: 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:generate
Step 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

Step 14: Modify permissions

sudo chown -R www-data:www-data /var/www
sudo chmod -R 777 /var/www/laravel-project/storage
Step 15: Restart Nginx and PHP7 fpm

service nginx restartservice php7.1-fpm restart
<span style="color:#000000">搞定!</span>
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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Task Management Tools: Prioritizing and Tracking Progress in Remote ProjectsTask Management Tools: Prioritizing and Tracking Progress in Remote ProjectsMay 02, 2025 am 12:25 AM

Taskmanagementtoolsareessentialforeffectiveremoteprojectmanagementbyprioritizingtasksandtrackingprogress.1)UsetoolslikeTrelloandAsanatosetprioritieswithlabelsortags.2)EmploytoolslikeJiraandMonday.comforvisualtrackingwithGanttchartsandprogressbars.3)K

How does the latest Laravel version improve performance?How does the latest Laravel version improve performance?May 02, 2025 am 12:24 AM

Laravel10enhancesperformancethroughseveralkeyfeatures.1)Itintroducesquerybuildercachingtoreducedatabaseload.2)ItoptimizesEloquentmodelloadingwithlazyloadingproxies.3)Itimprovesroutingwithanewcachingsystem.4)ItenhancesBladetemplatingwithviewcaching,al

Deployment Strategies for Full-Stack Laravel ApplicationsDeployment Strategies for Full-Stack Laravel ApplicationsMay 02, 2025 am 12:22 AM

The best full-stack Laravel application deployment strategies include: 1. Zero downtime deployment, 2. Blue-green deployment, 3. Continuous deployment, and 4. Canary release. 1. Zero downtime deployment uses Envoy or Deployer to automate the deployment process to ensure that applications remain available when updated. 2. Blue and green deployment enables downtime deployment by maintaining two environments and allows for rapid rollback. 3. Continuous deployment Automate the entire deployment process through GitHubActions or GitLabCI/CD. 4. Canary releases through Nginx configuration, gradually promoting the new version to users to ensure performance optimization and rapid rollback.

Scaling a Full-Stack Laravel Application: Best Practices and TechniquesScaling a Full-Stack Laravel Application: Best Practices and TechniquesMay 02, 2025 am 12:22 AM

ToscaleaLaravelapplicationeffectively,focusondatabasesharding,caching,loadbalancing,andmicroservices.1)Implementdatabaseshardingtodistributedataacrossmultipledatabasesforimprovedperformance.2)UseLaravel'scachingsystemwithRedisorMemcachedtoreducedatab

The Silent Struggle: Overcoming Communication Barriers in Distributed TeamsThe Silent Struggle: Overcoming Communication Barriers in Distributed TeamsMay 02, 2025 am 12:20 AM

Toovercomecommunicationbarriersindistributedteams,use:1)videocallsforface-to-faceinteraction,2)setclearresponsetimeexpectations,3)chooseappropriatecommunicationtools,4)createateamcommunicationguide,and5)establishpersonalboundariestopreventburnout.The

Using Laravel Blade for Frontend Templating in Full-Stack ProjectsUsing Laravel Blade for Frontend Templating in Full-Stack ProjectsMay 01, 2025 am 12:24 AM

LaravelBladeenhancesfrontendtemplatinginfull-stackprojectsbyofferingcleansyntaxandpowerfulfeatures.1)Itallowsforeasyvariabledisplayandcontrolstructures.2)Bladesupportscreatingandreusingcomponents,aidinginmanagingcomplexUIs.3)Itefficientlyhandleslayou

Building a Full-Stack Application with Laravel: A Practical TutorialBuilding a Full-Stack Application with Laravel: A Practical TutorialMay 01, 2025 am 12:23 AM

Laravelisidealforfull-stackapplicationsduetoitselegantsyntax,comprehensiveecosystem,andpowerfulfeatures.1)UseEloquentORMforintuitivebackenddatamanipulation,butavoidN 1queryissues.2)EmployBladetemplatingforcleanfrontendviews,beingcautiousofoverusing@i

What kind of tools did you use for the remote role to stay connected?What kind of tools did you use for the remote role to stay connected?May 01, 2025 am 12:21 AM

Forremotework,IuseZoomforvideocalls,Slackformessaging,Trelloforprojectmanagement,andGitHubforcodecollaboration.1)Zoomisreliableforlargemeetingsbuthastimelimitsonthefreeversion.2)Slackintegrateswellwithothertoolsbutcanleadtonotificationoverload.3)Trel

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.