- Remove .env option from your .gitignore file.
- And push your project to the github.
- On AWS, find Lightsail from its service filter.
- Then create the instance. ( OS only, Ubuntu 20.04 )
- Let’s start!
(Login as root user)
- sudo su
(System update)
- apt-get update -y
- apt-get upgrade -y
(Configure Apache2, php 7.4, and composer environment)
- apt-get install apache2 php7.4 libapache2-mod-php7.4 php7.4-curl php-pear php7.4-gd php7.4-dev php7.4-zip php7.4-mbstring php7.4-mysql php7.4-xml curl -y
- sudo service apache2 restart
(Install Composer)
- curl -ss https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- chmod +x /usr/local/bin/composer
(Change the root directory)
- nano /etc/apache2/sites-available/000-default.conf
There, Update this option from DocumentRoot /var/www/html
To DocumentRoot /var/www/your_git_repo_name/public
( Go to root directory )
- cd /var/www
- git clone https://github.com/your_username/your_repo_name.git
- sudo chmod -R 777 your_project
- cd your_project
- composer install
Then check the IP if the project is working.
Then there might be a phenomenon that sub route doesn’t work.
If then,
- nano /etc/apache2/apache2.conf
Then update this.
from
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
To
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then apache2 restart
- sudo service apache2 restart
End. Hope it works well.
Thanks for reading!