
sudo yum update
sudo yum install httpd httpd-tools mod_ssl
sudo systemctl enable httpd sudo systemctl start httpd
sudo amazon-linux-extras enable php8.1
sudo yum clean metadata sudo yum install php php-common php-pear sudo yum install php-{cgi,curl,mbstring,gd,mysqlnd,gettext,json,xml,fpm,intl,zip} sudo yum install git
sudo chown -R ec2-user:apache /var/wwwsudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;find /var/www -type f -exec sudo chmod 0664 {} \;
sudo vi /var/www/html/info.php
cd /var/www/html/laratest
1.2 Create virtual host and add domains
sudo vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80> DocumentRoot /var/www/html/laratest/public <Directory /var/www/html/laratest/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all Require all granted </Directory></VirtualHost>
<VirtualHost *:80> ServerName subdomain.domain.com DocumentRoot /var/www/html/laratest/public <Directory /var/www/html/laratest/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all Require all granted </Directory></VirtualHost>
1.3 Add another project
cd /var/www/htmlcp -r laracast laracast2
sudo chown -R ec2-user:apache /var/www sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \; find /var/www -type f -exec sudo chmod 0664 {} \;
<VirtualHost *:80> ServerName subdomain2.domain.com DocumentRoot /var/www/html/laratest2/public <Directory /var/www/html/laratest2/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all Require all granted </Directory></VirtualHost>
2. Add GitHub Actions Laravel on EC2 server
2.1 Creating your first workflow
# Trigger deployment only on push to master branch
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy to EC2 on master branch push
runs-on: ubuntu-latest
steps:
- name: Checkout the files
uses: actions/checkout@v2
- name: Deploy to EC2
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.EC2_HOST }}
REMOTE_USER: ${{ secrets.EC2_USERNAME }}
TARGET: ${{ secrets.TARGET_DIR }}
push:
branches:
- develop
3. Add SSL with lets encrypt
sudo amazon-linux-extras install epelsudo yum install certbot python2-certbot-apache
sudo certbot –apache
<VirtualHost *:80> ServerName laratest.vimuthonline.live DocumentRoot /var/www/html/project1/public <Directory /var/www/html/project1/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all Require all granted </Directory> RewriteEngine on RewriteCond %{SERVER_NAME} =laratest.vimuthonline.live RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]</VirtualHost>
4. Laravel coding
Related Articles

Maximizing User Experience: The Key to Success in Graphical Application Development framework
By Luigi Laezza

Filtering User Input: Safeguarding Your Textbox from Unwanted Characters framework
By Luigi Laezza

Unlocking the Potential of No-Code and Low-Code Platforms for Entrepreneurs framework
By Luigi Laezza

Mastering Laravel Email: Configuration and Command-Line Testing
By Luigi Laezza

Unlocking the Potential of AI with No-Code and Low-Code Platforms framework
By Luigi Laezza

Integrating Facebook and Instagram APIs with Meta: A Guide to Enhance Your Brand's Social Media Strategy framework
By Luigi Laezza

Selbstbedienungskassen: Die Zukunft des Einkaufens mit maßgeschneiderter Software framework
By Luigi Laezza

Mastering Laravel: Your Comprehensive Guide to Web Development framework
By Luigi Laezza