LaravelSystem Administration

Install Laravel In Ubuntu 20.04 “LTS”

Laravel is one of the best PHP frameworks for developing web applications. It has a ton of features that otherwise are time-consuming to build a PHP app from scratch.

Some of the best features of Laravel are, it is easily customizable, the great authentication system, and a huge collection of packages created by the community. In this article, I will walk you through how to install the Laravel framework in Ubuntu 20.04 LTS or Linux Mint 20. This should also work for any other Ubuntu version or Ubuntu derivatives.

If you are thinking about deploying your Laravel application, then you can use massiveGRID or digitalocean. Both of these companies will let you set up your web server in no time.

Recently I have seen people having trouble with installing Laravel with the latest versions of PHP. To get the most from PHP or Laravel, it is recommended to use the latest version of PHP.

Install or upgrade to the latest PHP version

Install the latest PHP version from ondrej PPA for Ubuntu.

sudo add-apt-repository ppa:ondrej/php
sudo apt upgrade
sudo apt install php
sudo apt install apache2
  • PHP (7.0, 7.1, 7.2, 7.3, 7.4) (Latest version is recommended)

Laravel requires the following PHP packages to function properly. To install each of them before heading forward to the next step.

Required PHP Extensions

sudo apt install php-bcmath
sudo apt install php-json
sudo apt install php-mbstring
sudo apt install php-xml
sudo apt install php-tokenizer
sudo apt install php-zip

Enable PHP fileinfo extension in Ubuntu

To enable PHP fileinfo and PHP OpenSSL in Ubuntu or derivatives, uncomment the extension in the php.ini file. Open php.ini file located in /etc/php/7.4/apache2/php.ini. Change the PHP version in the path. For instance, my currently activated PHP version is 7.4, so I need to edit the php.ini file inside 7.4 directory.

sudo nano /etc/php/7.4/apache2/php.ini
  • Press ctrl + w and search for fileinfo. Remove the semi-colon to enable the extension.
  • Press ctrl + w and search for openssl. Remove the semi-colon to enable the extension.
enable php fileinfo extension ubuntu
enable PHP fileinfo extension ubuntu

Enable PHP openssl extension

enable php openssl extension in ubuntu
enable PHP openssl extension in ubuntu

Install Composer in Ubuntu

Composer is a dependency manager for PHP. It makes the installation of PHP packages very easy. To install it on Ubuntu or Linux Mint or any other Ubuntu derivatives, run the following commands in the terminal –

php -r "copy('', 'composer-setup.php');"

sudo php composer-setup.php --install-dir=/bin --filename=composer

Install Laravel

Once the composer is installed, it now turns to install laravel.

composer global require laravel/installer
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrc

And that’s it. You can now run the laravel command to craft your new laravel application.

laravel new MyApplication

Set up laravel app with authentication.

laravel new MyApplication --auth

The above will install and set up Laravel 7.x in your Ubuntu installation. If you have any difficulty with any of the steps mentioned above, please let me know in the comment section below.


karani August 2, 2020 at 2:25 pm

Hi, thanks very informative.

I got stuck at the very last point where we are to craft a new laravel application. I get the following error”bash: laravel: command not found”

Sohail August 14, 2020 at 12:09 pm

Hi Karani,

That probably happened due to setting incorrect $path. What distribution are you using?

Leaf Mabz August 23, 2020 at 10:55 am

Because it should be
echo ‘export PATH=”$PATH:$HOME/.config/composer/vendor/bin”‘ >> ~/.bashrc
instead of

echo ‘export PATH=”$PATH:$HOME/.composer/vendor/bin”‘ >> ~/.bashrc

hero September 29, 2020 at 9:02 pm

stock in last using ubuntu lts 20

Luke Marvelly October 13, 2020 at 2:50 pm

The command:

sudo apt install php-ctype

doesn’t work either. It tells me I need to select an option:

Package php-ctype is a virtual package provided by:
You should explicitly select one to install.

Luke Marvelly October 13, 2020 at 2:55 pm

Used this in the end:

sudo apt install php7.3-ctype

Luke Marvelly October 13, 2020 at 3:08 pm

This line didn’t work for me either:

source ~/.bashrc

Luke Marvelly October 13, 2020 at 3:40 pm

Btw I’m using Linux Mint 19.3

Sohail November 6, 2020 at 8:45 pm

No problem. It should work with Linux Mint too.

marcel December 7, 2020 at 3:38 am

Worked like a charm in Mint 20.3, except it denied the existence of the –auth option.


Sass January 31, 2021 at 10:06 am

Dear Sohail
Thanks so much your commands works.Everything was well. Thank you so much

Sohail February 8, 2021 at 2:58 pm

Hi Sass,

Thanks a lot for reading. I am glad the article helped you.

Vila February 11, 2021 at 3:26 am

Running this:

laravel new MyApplication –auth

Shows this:

The “–auth” option does not exist.

I’m not sure seeing why yet…

I’m using WSL2 with Ubuntu 20 and Laravel Installer 4.1.1

Why am I getting this error when you’re not?


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.