How to Install Laravel Framework on Ubuntu

Laravel is an open-source and cross-platform PHP framework that is hailed by web developers everywhere. Laravel is built by Symfony framework and works on model-view-controller pattern. It is highly regarded because it cuts down the grunt work and lets the developers do the real work.

In this article, You will learn how you can install and set up the Laravel framework on your Ubuntu System.


  • Ubuntu Linux-based system
  • Terminal access
  • A user account with sudo privileges.

Note: The commands in this tutorial are executed on the Ubuntu 20.04 system. All the methods in the tutorial are valid for any Linux-based system.

Update & Upgrade the System

It is always the best practice to start any installation with the upgraded and updated system but it is necessary as Laravel does not work with PHP with a version lower than 7.2.

To update and upgrade your system, run the following command.

sudo apt update && apt upgrade -y

Update system packages

Install PHP

To install PHP on your system, run the following apt command.

sudo apt install php

Install PHP

Once you are done with the installation, check the installation version with the following command.

php -v

Check PHP version

Now install the PHP extension with the same version with the following command.

sudo apt install php7.4-mbstring php7.4-xml php7.4-zip

Install PHP packages

Install curl

Run the following command to install curl if you do not have it installed.

sudo apt install curl

Install curl

Install Composer

You need the Composer to manage dependencies in Laravel.

To install composer, run the following command.

curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer

Install Composer

Run the following command with your composer file path to run composer without sudo permission.

sudo chown -R $USER /usr/local/bin/composer/

Set permissions for composer

Install Symfony

Laravel often uses the Symfony framework so it is best to install it along with Laravel.

To install Symfony run the following command.

composer create-project symfony/skeleton testproj

Install Symfony framework

Change into the testproj directory and run the following command

run php -S -t public

Open the following link in the browser to verify the installation.


Symfony framework installed

Install Laravel

Now that everything is set and running, install Laravel using the following composer command.

composer global require laravel/installer

Install Laravel using Composer

Add Laravel to Path in Bashrc File

Once the Laravel installation is done, open the .bashrc file.

nano .bashrc

Edit .bashrc file

Then add the following line of code at the end of the file.

export PATH="$PATH:$HOME/.config/composer/vendor/bin"

.bashrc file content

Press Ctrl+O and Ctrl+X to save and exit.

Next source the bashrc file.

source ~/.bashrc

Apply .bashrc changes

Create New Laravel App

Simply run the following command to create an application in Laravel.

laravel new [name of app]

Create a new Laravel app

Navigate to the application directory and run the following composer command.

cd [name of app]
composer install

composer install

Now run the following commands to get the encryption key and access to localhost.

php artisan key:generate --ansi
php artisan serve

php artisan

Note the development server link and open it in the browser.


Laravel App

You can see Laravel is up and running.


This article discusses the installation process of Laravel and all the necessary components to establish a bare-minimum configuration. You can keep using the installation as it is to learn the Laravel basics or add more components like databases or homestead to build elaborate web applications.