How to install laravel in ubuntu 18.04

Laravel is a PHP web application framework with expressive, elegant syntax.  It is designed for the faster development of MVC web applications in PHP. In this article, we will install laravel 5 php framework on Ubuntu 19.04, 18.04 LTS, 16.04 LTS, 14.04 LTS operating systems. Please follow the steps below.

you will need to make sure your server meets the following requirements:

  • PHP >= 7.1.3
  • BCMath PHP Extension
  • Ctype PHP Extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Step 1 – Install LAMP :

Skip this step if LAMP is already installed. Otherwise , setup it using below Link

Step 2 – Install Composer

Skip this step if composer is already installed. Otherwise , setup it using below Link

Step 3  — Install Laravel

  We need to install latest version of Laravel from the official git repository.

Command :

$ cd /var/www

$ git clone
$ cd /var/www/laravel
$ sudo composer install

It may take some time to install dependencies. After above command completion we set the permissions on below files.

$ sudo chown -R www-data.www-data /var/www/laravel
$ sudo chmod -R 755 /var/www/laravel
$ sudo chmod -R 777 /var/www/laravel/storage

Step 4 –  Encryption key setup :

                        Rename the file .env.example to .env  in the project main directory.

Command :

  • $ mv .env.example .env

     Now we generate base64 random number encryption key, which used by the Illuminate encrypter service.

Command :

$ sudo php artisan key:generate

Application key set successfully.

make sure APP_KEY is properly set as generated in above command. To check this open .env file and see the app key as below :


It may be different in your machine.

Step 5 – Create Database for Laravel

You need to have database to connect with your Laravel application. So we create a MySQL database and user.


mysql> CREATE DATABASE laravel;
mysql> GRANT ALL ON laravel.* to 'laravel'@'localhost' IDENTIFIED BY 'linuxworld';
mysql> quit 

Now edit the .env file and update database settings.



Step 6 – Apache Configuration

Finallyconfigure Apahce2 site configuration file for Laravel application. Run the commands below to create a new configuration file called laravel.conf and open using this command

$sudo nano /etc/apache2/sites-available/laravel.conf

Then copy and paste the content below into the file and save it.


 <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/laravel/public
       <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/laravel>
                AllowOverride All
       ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


Save the file and exit

Step 6: Enable the Laravel and Rewrite Module

After configuring the VirtualHost above, enable it by running the commands below :

Command :

$ sudo a2ensite laravel.conf
$ sudo a2enmod rewrite

Reload Apache configuration changes by restarting service using below command

$ sudo service apache2 restart

Step 7 – Access Application

Congrats, Now LARAVEL 5 PHP framework has been configured on your system. Open the URL in your favourite browser. You will get  laravel default page on the browser.



All Done Enjoy 🙂

Read Also :



Leave a Reply

Your email address will not be published. Required fields are marked *