How To Deploy Laravel Application On AWS EC2 Ubuntu 22.04 Server ?

To deploy a Laravel application on an AWS EC2 Ubuntu 22.04 server, you can follow the below steps:

  • Create an EC2 instance: First, create an EC2 instance in your AWS account with Ubuntu 22.04 as the operating system.
  • Connect to your EC2 instance: After the instance is created, connect to it via SSH.
  • Update the server: Run the following commands to update your server:

Install Apache web server: Run the following command to install Apache web server:

Install PHP: Run the following command to install PHP:

Install necessary PHP extensions: Run the following command to install necessary PHP extensions:

Install MySQL: Run the following command to install MySQL:

Install Git: Run the following command to install Git:

Clone the Laravel application: Clone the Laravel application from your Git repository to the /var/www directory using the following command:

Set permissions: Set the correct permissions for the Laravel application directory and storage directory:

Configure Apache: Create a new Apache virtual host configuration file by running the following command:

Add the following configuration to the file:

Save and exit the file.

Enable the new virtual host: Run the following command to enable the new virtual host:

Restart Apache: Run the following command to restart Apache:

Configure the .env file: Create a new .env file by running the following command:

Edit the .env file and set the appropriate values for your application’s database and other configuration settings.
Run migrations: Run the following command to run the Laravel migrations:

Your Laravel application should now be deployed and running on your AWS EC2 Ubuntu 22.04 server. You can access it by visiting your server’s public IP address or domain name in your web browser.

Share on:

Hello, I am Dharmendra Yadav and I am a Python Developer with experience in web development using Django, Flask, REST API, SQL, MySQL, HTML, CSS, JavaScript, WordPress, Oracle Cloud, AWS and Git. I also write technical articles where I explain web development and Software Engineering. Facebook , Linkedin