Are you ready to take your Laravel application live?
It’s an exciting milestone — but for many developers, it’s also the part that feels the most daunting. Moving your project from a local environment to a live server can be tricky, with a lot of moving parts like server setup, database configuration, and file permissions to get right.
In this guide, I’ll show you two distinct methods for getting your Laravel application online. First, we’ll look at the manual method to get your Laravel app on your Amazon EC2 server.
Then, we’ll see how Cloudways can automate the entire process, allowing you to get your app live in a fraction of the time.
Let’s get started.
- Install Laravel on AWS (Manual Method)
- Install Laravel on AWS Using Cloudways (Easier Method)
- Step 1: Launch a New Cloudways Server on AWS
- Step 2: Locate Your Laravel App on the Server
- Step 3: Prepare Your Laravel Project for Upload
- Step 4: Upload the Project via FileZilla
- Step 5: Export Your Local Database
- Step 6: Import Your Database to Cloudways
- Step 7: Configure Laravel on the Server
- Step 8: Verify Your Laravel App on Cloudways
- Conclusion
Install Laravel on AWS (Manual Method)
This approach requires you to build your web server stack from the ground up, from launching your virtual machine to installing the necessary software, configuring your application, and getting it live on the web.
We’ll get into all that so follow each step carefully.
Prerequisites
Before we begin, you’ll need the following:
- An AWS Account: You can sign up for a new account and take advantage of the generous AWS Free Tier. You’ll need a credit card, but you won’t be charged as long as you stay within the free tier limits.
- A Laravel Project: Have your Laravel application ready to go. We’ll deploy it from a Git repository.
- A Windows Terminal: Windows 10 and 11 come with a built-in terminal that can handle SSH connections. We’ll be using this for all commands.
Step 1: Launch an EC2 Instance
The first step is to create the virtual server that will host your application. But before we do that, sign up for a free tier account.




- Log in to the AWS Management Console: Go to the AWS website and sign in to your account.
- Navigate to EC2: Use the search bar to find and select the EC2 service.

- Launch an Instance: Click the Instances option and then Launch Instances button.


- Name and OS: Give your instance a name, like “LaravelApp.” For the Amazon Machine Image (AMI), select Ubuntu Server 22.04 LTS.

- Instance Type: I’ll leave this to t3.micro to stay within the AWS Free Tier.

- Key Pair: Create a new key pair by clicking Create new key pair. Give it a name, choose .pem as the format.

- Once you click on the Create key pair button, the file will download automatically. Keep this file secure as you’ll need it to connect to your server.

- Network Settings: Click Edit next to “Network settings” and configure your security group. Click on the Add security group rule and add SSH, HTTP and HTTPS.

- SSH (Port 22): This allows you to connect to the server. You can select “My IP” for security.
- HTTP (Port 80): This is essential for web traffic. Set the source to “Anywhere.”
- HTTPS (Port 443): It’s a good practice to enable this for secure connections. Set the source to “Anywhere.”

- Launch: Finally, review the configurations of your instance in the summary window and then click the Launch instance button.



- Now in the Instances tab, you can see that the Instance State has changed to “running.”

Step 2: Connect and Install Software
Now, we’ll connect to the server and install the necessary software.
- Get Public IP: On the EC2 Instances page, select your instance and copy its Public IPv4 address.

- Connect via SSH: Open your Windows Terminal and navigate to the directory where you saved your .pem key file. Then, use the following command to connect. The default user for Ubuntu is ubuntu.

ssh -i "your-key-pair-name.pem" ubuntu@<your-ec2-public-ip>
The command I’ll run will be: ssh -i “laravel-aws-key.pem” [email protected]
- If prompted to continue connecting, type yes. You are now logged in to your server.

After typing yes, I’m connected:

- Update and Upgrade: Update the package list.
sudo apt update && sudo apt upgrade -y

- Install Web Server and PHP: We’ll use Nginx as our web server and install the necessary PHP extensions for Laravel.
sudo apt install nginx php-fpm php-mysql php-mbstring php-xml php-bcmath php-json php-zip unzip git curl -y

- Install Composer: Get Composer, Laravel’s dependency manager.
curl -sS https://getcomposer.org/installer | php

sudo mv composer.phar /usr/local/bin/composer
After running this command, you’ve successfully installed Composer globally on your server. This means you can now run composer commands from any directory on your EC2 instance, which is essential for managing your Laravel project’s dependencies.
Step 3: Deploy Your Laravel Project on Your EC2 Server
Next, we’ll get our project which is on our local machine to the EC2 server. The most common and straightforward method is to use a secure file transfer protocol like SCP (Secure Copy Protocol). This works through your SSH connection.
- Compress Your Project: First, on your local machine (Windows), create a compressed .zip archive of your Laravel project folder.
- Make sure to exclude the node_modules and vendor directories to keep the file size manageable.
- You can easily do this by right-clicking your project folder and selecting Send to > Compressed (zipped) folder.

What to do after zipping?
Transfer the zipped file: You’ll use this command in your Windows Terminal to copy the zip file to your EC2 instance.
scp -i "your-key-pair-name.pem" "your-project.zip" ubuntu@<your-ec2-public-ip>:/home/ubuntu/
Placeholders to Update:
“your-key-pair-name.pem”: This is the name of the private key file you downloaded.
<your-ec2-public-ip>: This is the public IP address of your EC2 instance.
My modified code looks like this:
scp -i “C:\Users\abdulrehman\Downloads\laravel-aws-key.pem” “C:\Users\abdulrehman\live-search-project-folder.zip” [email protected]:/home/ubuntu/
But, you won’t run this command in the terminal that is connected to your EC2 server. Instead, open a new Command Prompt window. And run the command here.
This command will securely copy your project’s zip file from its location on your Windows laptop to the /home/ubuntu/ directory on your AWS EC2 instance.
In the screenshot below, you can see the progress of the file transfer.

Now we need to unzip the project folder we moved to our server and move the files to the correct directory.
The scp command we ran earlier placed your file in /home/ubuntu/. We need to move it to /var/www/, which is a common location for web applications.
sudo mv /home/ubuntu/live-search-project-folder.zip /var/www/
Navigate to the web directory:
cd /var/www/
Unzip the file: This will extract your project’s contents into a new folder.
sudo unzip live-search-project-folder.zip
After these commands, you can delete the zip file to save space with:
sudo rm live-search-project-folder.zip.
Since we didn’t transfer the vendor folder when we moved the zipped project folder to our server, we must now install all of our project’s PHP dependencies using Composer.
Navigate to your project folder:
cd /var/www/live-search-project-folder
Run the Composer install command:
sudo composer install --optimize-autoloader --no-dev
When you run the command, you might see a warning that you’re running Composer with sudo. This is generally discouraged by the Composer team for security reasons, but it’s just a warning — not an error. Just type yes and press Enter. Composer will then proceed to download and install all the necessary PHP dependencies for your Laravel project.

Step 4: Create a Database and User on the EC2 Server
Now that you’ve got your project’s files on the server and its PHP dependencies installed with Composer, the next crucial step is to get the database from your local machine onto the EC2 instance.
At this point, my Laravel project is running on my AWS EC2 server, but its database is still on my local machine. I had originally created it using phpMyAdmin, and since this project is about live search, the database already has a few products in it.
Now that the project is moved to the EC2 server, I also need to move its database. I’ve already exported it from phpMyAdmin as a .sql file, and now I need to import that file onto the EC2 server.

This process has two parts:
- Creating a new, empty database on the EC2 server.
- Importing my local data (the .sql file) into it.
Install the MySQL Client:
sudo apt update
This command refreshes the server’s list of available software, ensuring you’re getting the latest package information before you install anything.
sudo apt install mysql-server -y
This single command installs the full MySQL server on your EC2 instance. The server package automatically includes the MySQL client that allows you to connect to the database from the command line. The -y flag automatically confirms the installation, so you don’t have to manually type ‘yes‘ to proceed.
Log in to MySQL:
sudo mysql

Create a database:
Run the following SQL commands one by one, pressing Enter after each one. Remember to replace ‘your_secure_password‘ with a unique and strong password.
CREATE DATABASE live_search_db;
Create a user:
CREATE USER 'live_search_user'@'localhost' IDENTIFIED BY 'your_secure_password';
Grant privileges:
GRANT ALL PRIVILEGES ON live_search_db.* TO 'live_search_user'@'localhost';
Apply changes and exit:
FLUSH PRIVILEGES; EXIT;
Step 5: Import the SQL File
Now, you’ll import the data from your local .sql file into the new database. You will run this command on a new CMD window, just like you did when you moved your zipped project folder to your EC2 server.
- Open a new CMD window on your Windows laptop.
- Run the SCP command to transfer the file to your EC2 instance.
scp -i "C:\Users\abdulrehman\Downloads\laravel-aws-key.pem" "C:\Users\abdulrehman\Downloads\live_search_db.sql" [email protected]:/home/ubuntu/

- Switch back to your server-connected CMD window and import the database.
sudo mysql -u live_search_user -p live_search_db < /home/ubuntu/live_search_db.sql
- You will be prompted to enter the password for live_search_user.

Step 6: Configure the Environment and Finalize
Now your database is ready. Go back to your project directory to update the .env file and set up your web server.
Open the .env file:
sudo nano /var/www/live-search-project-folder/.env

- Update the APP_URL and database credentials with the information you just created. You must manually change the DB_* variables in the .env file to match the database you created.

Save and exit: Press Ctrl + O, then Enter, and Ctrl + X.
Generate a new application key:
Navigate to your project folder using this command: cd /var/www/live-search-project-folder
Then run the php artisan command:
php artisan key:generate

Set permissions for the web server:
sudo chown -R www-data:www-data /var/www/live-search-project-folder
sudo chmod -R 775 /var/www/live-search-project-folder/storage /var/www/live-search-project-folder/bootstrap/cache
Configure Nginx to serve your Laravel app:
sudo nano /etc/nginx/sites-available/laravel
After you run sudo nano /etc/nginx/sites-available/laravel, the file will be empty. You need to paste the following code into it. Be sure to replace <your-ec2-public-ip> with your actual EC2 instance’s public IP address.
server {
listen 80;
server_name <your-ec2-public-ip>;
root /var/www/live-search-project-folder/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Enable and restart Nginx:
sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
- Once all these steps are complete, your application should be live and accessible at your EC2 instance’s public IP address.


Phew! And we are done. As you’ve experienced firsthand, the process of manually deploying a Laravel application to an AWS EC2 instance is quite tedious.
It requires a deep understanding of each component of the web stack, from the virtual machine and network settings to the web server, PHP, Composer, and MySQL.
Install Laravel on AWS Using Cloudways (Easier Method)
Now we’ll see how Cloudways makes the same process much simpler.
Step 1: Launch a New Cloudways Server on AWS
- Sign Up and Log In: Go to the Cloudways website and sign in.
- Add a Server: Click the “Add Server” button on your dashboard.
- Select Your Application: Choose the “Laravel” application and give it a name like “LaravelApp.”
- Choose AWS: In the cloud provider section, select the AWS tab.
- Select Server Size and Location: Choose your desired server size (e.g., a t3.micro to match the free tier) and a data center location.
- Launch: Click “Launch Now.” Cloudways will take over, automatically provisioning your AWS EC2 instance and installing and configuring the entire Laravel-ready stack, including Nginx, PHP, and MySQL.
This single step on Cloudways replaces a lot of the manual EC2 process, where you had to launch the instance, configure security groups, and then manually install all the software.
Since I already have an AWS server ready, I’ll just install a new Laravel app on it and give it a name.


Step 2: Locate Your Laravel App on the Server
After the server finishes launching, go to the Applications tab in your Cloudways dashboard. Click on your Laravel application’s name.
Now, you’ll see a list of access details. Click the Application URL to open your site in a new browser tab.

At this stage, you’ll see Cloudways’ default welcome page, not Laravel’s. This is normal because your Laravel project files haven’t been uploaded yet.

Step 3: Prepare Your Laravel Project for Upload
On your local machine, open your Laravel project folder. Before you upload it to the server, you need to remove two large and unnecessary items to save time and prevent conflicts:

- The vendor/ folder: This folder contains all of your project’s PHP dependencies. We’ll rebuild it on the server with composer install.
- The .env file: This file contains your local environment variables and database credentials. You’ll create a new one on the server with the correct Cloudways credentials.
Step 4: Upload the Project via FileZilla
- Get Your SFTP Credentials: In your Cloudways dashboard, go to the Servers tab and click on Master Credentials. Copy the Public IP, username, and password. The port is always 22.

- Connect with FileZilla: Open FileZilla and enter the credentials to connect to your server.
- Navigate to the Correct Directory: On the remote site pane (right side), navigate to /applications/[your_app_username]/public_html.
- Upload Files: On the local site pane (left side), open your Laravel project folder. Drag all the files and folders (except vendor/ and .env) from your project to the public_html directory on the server.
This process securely uploads all of your Laravel project’s code to the server.
Step 5: Export Your Local Database
- Access phpMyAdmin: On your local machine, open your browser and go to http://localhost/phpmyadmin.
- Select Your Database: Click on your live_search_db from the left sidebar.
- Export the Database: Click the Export tab from the top menu.

- Download the SQL File: Leave the export method as Quick and the format as SQL. Click the Export button to download the .sql file to your computer. This file contains all your tables and data.

Step 6: Import Your Database to Cloudways
- Launch Database Manager: In your Cloudways dashboard, navigate to the Applications tab and click on your Laravel application. On the left menu, select Access Details and then click the Launch Database Manager button.

- Import the SQL File: Inside the Database Manager, click the Import tab. Select the .sql file you just exported from your local machine and click Import.

Once this is complete, your Cloudways database will contain the same tables and data as your local setup.

Step 7: Configure Laravel on the Server
This step is crucial for making your application work on the server.
Access the SSH Terminal:
In your Cloudways dashboard, go to your application’s page and click on the Master Credentials section. Here, you’ll find the SSH login command. Alternatively, you can open your web-based SSH terminal in the dashboard.
Install Dependencies:
cd applications/[your_app_username]/public_html
composer install
Create the .env File:
cp .env.example .env
Generate the App Key:
php artisan key:generate
Edit the .env File:
nano .env
- Update the database and app URL variables with the credentials provided in your Cloudways dashboard under Application Access Details.
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_cloudways_db_name DB_USERNAME=your_cloudways_db_username DB_PASSWORD=your_cloudways_db_password APP_URL=https://your-cloudways-app-url APP_DEBUG=true

- Set APP_DEBUG=true temporarily to help with any potential errors. Once your app is live, change it back to false for security.
- Save the File: Press Ctrl + X, then Y, and finally Enter.
Step 8: Verify Your Laravel App on Cloudways
With everything configured, your application should be live. To check it, simply go back to your Cloudways dashboard, navigate to the Applications tab, and click on your Application URL.

If all the steps were followed correctly, your Laravel live search app will be running smoothly on the server, just as it did locally.

Conclusion
In this guide, we explored two different ways to deploy a Laravel live search app — the hands-on approach on Amazon EC2 and the managed route on Cloudways.
The EC2 setup gave us complete control over the stack — from launching the server and configuring security groups to installing Nginx, deploying our code, and setting up the database.
It takes more effort, but it’s a great way to understand how everything fits together behind the scenes.
In contrast, Cloudways handled most of the heavy lifting. We simply uploaded the project via FTP, imported the database, updated the .env file, and set permissions — and the app was live with minimal friction.
If you want full control and a deeper understanding of server administration, EC2 is the way to go. But if speed and simplicity matter more, Cloudways makes getting your app online much faster and far less stressful.
Frequently Asked Questions
Q. How to install Laravel in AWS?
A: You can install Laravel on AWS either manually or with a managed service. The manual method involves launching an EC2 instance and installing all the software (Nginx, PHP, MySQL, Composer) yourself. A managed service like AWS Elastic Beanstalk automates this process by deploying your code and configuring the environment for you.
Q. Can I host PHP on AWS?
A: Yes, you can. AWS is a very popular platform for hosting PHP. Common services for PHP include Amazon EC2 for full control, AWS Elastic Beanstalk for automated deployment and scaling, and AWS Lambda for a serverless approach.
Q. Can I host my backend on AWS?
A: Yes, you can. AWS is a leading provider for backend hosting. You can use Amazon EC2 for a traditional server, AWS Lambda for a serverless backend, or Amazon ECS for a containerized backend. These services offer different levels of control and management to suit your needs.
Abdul Rehman
Abdul is a tech-savvy, coffee-fueled, and creatively driven marketer who loves keeping up with the latest software updates and tech gadgets. He's also a skilled technical writer who can explain complex concepts simply for a broad audience. Abdul enjoys sharing his knowledge of the Cloud industry through user manuals, documentation, and blog posts.