How to deploy your Laravel 8 project on Ubuntu 20.04

Highdream
1 min readMay 18, 2021
  • Remove .env option from your .gitignore file.
  • And push your project to the github.
  1. On AWS, find Lightsail from its service filter.
  2. Then create the instance. ( OS only, Ubuntu 20.04 )
  3. 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)

(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 )

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!

--

--