How to Install Laravel on Ubuntu 16.04

r00t August 19, 2017

Install Laravel on Ubuntu 16.04

In this tutorial we’ll learn how to install Laravel on Ubuntu 16.04. We will also install and configure its prerequisites. Laravel is an open source PHP framework based on the MVC (Model View Controller). Laravel makes it easier for a developer to write web applications. Laravel is considered the best framework to write PHP applications together with other frameworks. Laravel provides a modular packaging system and a dedicated dependency manager. It supports many different relational databases and provides different ways for accessing them.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Laravel on Ubuntu 16.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing LAMP on Ubuntu 16.04.

You should check out this LAMP stack install tutorial for Ubuntu 16.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that Laravel relies on:

apt-get install php7.0-mysql php7.0-curl php7.0-cgi php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-gd php7.0-mbstring php7.0-xml

Step 3. Installing Composer.

Composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system:

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

Step 4. Installing Laravel Framework.

Download the latest version of Laravel using the commands below:

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
composer install

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

Step 5. Set Encryption Key.

Now set the 32 bit long random number encrypption key, which used by the Illuminate encrypter service:

php artisan key:generate
Application key [WRAGp0Pu9kTHiZBMWe46KGR4NtY6iF] set successfully.

Then update the above generated application key into the config/app.php configuration file. Also make sure that cipher is set properly:

'key' => env('WRAGp0Pu9kTHiZBMWe46KGR4NtY6iF')/ This key is used by the Illuminate encrypter service and should be set. 
'cipher' => 'AES-256-CBC',

Step 6. Create Apache Virtual Host.

Now create a Virtual Host in your Apache configuration file to access Laravel framework from web browser:

### 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:

service apache2 reload

Step 7. Accessing Laravel Web Installation.

Now you can access the Laravel web install wizard in your browser by entering the domain name or http://your ip/ and you will see the application running.

Congratulation’s! You have successfully install and configured Laravel on your Ubuntu 16.04 server.

The Tags:

Leave a Comment

Comments are closed.