How to Install Laravel on Ubuntu 20.04

Install Laravel on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure Laravel on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Laravel is a very popular open-source PHP framework with the expressive and elegant syntax used to design modern and beautiful web applications. Laravel aims to take the pain out of web development and make it an enjoyable and creative experience, turning web devs into web artisans.

Install Laravel on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

Step 2. Install LAMP Stack.

You need to setup LAMP stack on your Ubuntu system. If you haven’t done so already, use our traditional LAMP guide to set up Ubuntu to serve PHP before you continue.

Step 3. Install Composer.

Composer a dependency manager tool for PHP programming language. We will use it to download and install the Laravel Core and all the required Laravel components:

Finally, verify that the composer installed correctly by running:

Step 4. Install Laravel on Ubuntu system.

First, clone the master branch of the Laravel from GitHub repository:

Next, change the Laravel directory and use the composer to install all dependencies required for the Laravel framework:

Then, set the directory permissions accordingly:

Step 5. Create Environment Settings.

Now we create the Laravel environment configuration file:

Then, generate base64 random number encryption key:

AFter generate random encryption, now we edit the .env configuration file and update the required settings. Also, make sure APP_KEY is properly set as generated in the above command:

Step 6. Creating a MariaDB database for Laravel.

Laravel uses MariaDB database to store all its data like posts, pages, users, plugins and themes settings. Log in to your MariaDB server with the following command and enter your MariaDB root password:

Once you’re in the MariaDB console, create a new database:

Then, edit the .env file and update database settings:

Step 7. Configuring Apache for Laravel.

Create a new virtual host configuration file for your Laravel website, named

And add the following content to the file:

To enable the virtual host we have just created, run the following command:

For the new configuration to take effect, restart the Apache service by typing:

Step 8. Setup Laravel.

Now you can access the Laravel web install wizard using an HTTP connection:

That’s all you need to do to install Laravel on Ubuntu 20.04 Focal Fossa. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.