Install Laravel php Framework on Ubuntu 16.04

It is about Install Laravel. Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller (MVC) architectural pattern.

In this article, we are going to demonstrate how to up and run Laravel 5.x on Ubuntu 16.04 LTS, 15.04 LTS, 14.04 LTS, 12.04 LTS.

Prerequisites & Environment to Install Laravel

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

  • A Host System(Mac, Linux, Windows) with LAMP server.
  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

So let’s start installing Laravel from scratch:

Step1: — Installing LAMP Server to host

Click to view how to install LAMP and Virtual Host in detail:

  • Installing Apache2
$ sudo apt-get update
$ sudo apt-get install python-software-properties 
$ sudo apt-get install -y apache2 libapache2-mod-php
  • Installing MySQL 
$ sudo apt-get install -y mysql-server php-mysql
  • Installing PHP and required Module
$ sudo apt-get install -y php php-mcrypt php-mbstring php-xml php-gd

Step2: — Installing Few Utility Tools

You need few utility tools to proceed further if you are using a minimal version of Ubuntu server otherwise you can ignore the step 2.

  • Installing CURL, git, nano editor, unzip
$ sudo apt-get install -y curl unzip git nano

Step3: — Installing Composer

Composer is required for installing Laravel dependencies. In order to download and install composer use below commands.

$ curl -sS | php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo chmod +x /usr/local/bin/composer

Step4: — Installing Laravel Framework: 

Clone and download the latest version of Laravel. Use below command to clone master repo of laravel from GitHub.

$ cd /var/www
$ git clone

After completing clone and download move on laravel directory and use composer to install all dependencies required for Laravel framework.

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

Try to avoid root user for run Composer because Certain Composer commands, including exec, install, and update allow third party code to execute on your system. This is from its “plugins” and “scripts” features. Plugins and scripts have full access to the user account which runs Composer. For this reason, it is strongly advised to avoid running Composer as super-user/root.

After install all dependencies, change ownership of your web dir Laravel under www directory and change following permission.

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

Step5: — Setting Encryption Key to App:

Make sure that your present working directory is laravel (/var/www/laravel).

Before generating Key. Copy or rename the .env.example file to .env file otherwise, you will get an error while generating the key.

 $ cp /var/www/laravel/.env.example /var/www/laravel/.env

Now generate a  32 bit long random number encryption key, which used by the Illuminate encrypted service.

$ php artisan key:generate
Application key [base64:5zcSAFWQ+379F/TZsxxVmJMeO2R19b1FTi2aD280/Yo=] set successfully.

Now it’s time to put the Application Key at “app.php” file. Let’s edit config/app.php configuration file and update above generated application key as followings. Also, make sure cipher is set properly. find the following at 106 no line:

'key' => env('APP_KEY', 'base64:5zcSAFWQ+379F/TZsxxVmJMeO2R19b1FTi2aD280/Yo='),

'cipher' => 'AES-256-CBC',

Step6: — Setting up Apache Virtual Host: 

Now add a Virtual Host in your Apache configuration file to access Laravel framework from a web browser. Create Apache configuration file under /etc/apache2/sites-available/ directory and add below content.

 $ sudo nano /etc/apache2/sites-available/
<VirtualHost *:80>
 DocumentRoot /var/www/laravel/public
 <Directory />
    Options FollowSymLinks
    AllowOverride None
 <Directory /var/www/laravel>
     AllowOverride All
   ErrorLog ${APACHE_LOG_DIR}/error.log
   LogLevel warn
   CustomLog ${APACHE_LOG_DIR}/access.log combined

Now enable the virtual host and reload apache service. using below command.

$ sudo a2ensite
$ sudo service apache2 reload

Now you have completed the installation of Laravel 5.x successfully. To access your site follow the one more step.

Step7: — View / Access Laravel: 

We assume that you are on a test server so, to access Laravel make host file entry to access your Laravel application in the web browser. Change with your server ip and with your domain name configured in Apache to your accessing system. if you are in Linux or Mac then follow the path /etc/hosts and if you are accessing through windows system then follow the C:/Windows/System32/drivers/etc/hosts and insert the following line.

  • For Linux:
$ sudo echo "" >> /etc/hosts
  • For Windows
# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.

# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
# source server
# x client host
# localhost name resolution is handled within DNS itself.
#       localhost
# ::1             localhost

#If your server on same host that you are use for access

# Or

#<your Server Ip>

And access in your favourite web browser as below.

access laravel

Now build your awesome app using Laravel.

One Step Method of  Install Laravel on Ubuntu 14.04 and above:

If you are puzzled on above code and steps then sit back and relax. we are here for you, everything will do our shell script. Execute following code on your terminal:

 $ bash <(curl -s

Enter your website name when it asking for FQDN name for example ( After that when it will be prompted for MySQL root password. Then you have to enter a password whichever you want to set. For your information, the following script sets your web directory at /home/<your site>/public_html/laravel. Nothing else enjoy Laravel.

  • See On Youtube how to install Laravel:


The following two tabs change content below.

Subroto Mondal

Chief Coordinator HR&CR
I like Programming and New Technologies. And work with Linux.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.