
Introduction:-
- Amazon EC2 is a popular cloud service for deploying and managing web applications, including Laravel websites.
- This guide outlines the steps to launch a Laravel website on an EC2 instance, making it easy to run your application in the cloud.
Prerequisites:-
- An AWS (Amazon Web Services) account.
- An SSH key pair for secure access to your EC2 instance.
- Basic knowledge of Laravel and web server setup.
Here Is Step by Step Process,
- Launch an Amazon EC2 Instance:-
- Sign in to your AWS Management Console.
- Navigate to the EC2 Dashboard.
-
- Choose an Amazon Machine Image (AMI):-
- Select a suitable AMI for your Laravel project. A popular choice is the Amazon Linux 2 AMI.
- Choose an instance type based on your project's requirements
- Configure instance details, such as the number of instances and network settings, as needed.
- Configure Security Groups:-
- Create a new security group or use an existing one.
- Open ports 80 (HTTP) and 443 (HTTPS) to allow web traffic
- Open port 22 (SSH) for secure access to your instance.
- Review And Launch:-
- Review your instance settings and click "Launch."
- Select an existing SSH key pair or create a new one.
- Click "Launch Instances."
- Connect to Your EC2 Instance :-
- Once your instance is running, use SSH to connect to it. Replace and with your key pair file and instance's public IP address.
ssh -i ec2-user@your-instance-ip
Deploy Laravel Project and nginx version:-
-
sudo su -
add-apt-repository ppa:nginx/stable
7. Update Libraries With Nginx Latest version:-
-
apt-get update
-
apt-get install nginx
8.Install PHP and Other Packages:-
-
apt-get install python-software-properties -
add-apt-repository ppa:ondrej/php
9. Install PHP 8.1:-
-
sudo apt-get install php8.1 php8.1-mysql php8.1-fpm php8.1-xml php8.1-gd php8.1-opcache php8.1-mbstring -
apt-get install zip unzip php8.1-zip
10.Clone Your Project From Github:-
-
cd /var/www
-
git clone
-
cd
11.Server Configuration :-
-
cd /etc/nginx/sites-avaliable/
-
sudo vi Laravel Go to Laravel official website and search for Server configuration and copy the code and paste the code after above command.And set server name with your domain-name and root directory path of your project and change the php version which you are using and save the changes.-
cd ../sites-enabled/ -
sudo ln ../sites-avaliable/Laravel -
vi Laravel -
sudo rm Laravel -
sudo ln -s ../sites-avaliable/Laravel . -
sudo service nginx restart
12. Give Permission To Your Project :-
-
cd /var/www/your-project -
sudo chown -R www:data:www-data folder-name -
sudo service nginx restart
13. Connect to Go daddy Database :-
Update your .env file with your go daddy IP address and restart nginx service
14. Secure Your Website With SSL :-
-
sudo certbot -nginx -
sudo apt install certbot
-
sudo certbot -nginx
-
sudo certbot -nginx -d your-project-name -
sudo service nginx restart


