HomeHow ToHow to Install Laravel 5.5 on Ubuntu 16.04 with Apache

How to Install Laravel 5.5 on Ubuntu 16.04 with Apache

If you are reading this then you already know what the heck is Laravel. To wrap it up in a single line, it is one of the best PHP framework available right now with MVC(Model-View-Controller) Architecture.

You should learn Laravel if you already are familiar with the Core PHP. This is because while developing large projects there are several issues like update management, code management and much more.

A framework provides a way to do separate things in different ways making it easier to develop and update. Some of the things I really liked about Laravel are inbuilt authentication system, easy validations, and Eloquent model.

Install Laravel On Ubuntu

There are several tutorials available on the internet for installing but while following them I was unable to setup laravel completely. So I collected all the errors and googled to fix them and wrote them one by one and compiled this tutorial.

So without any further due let’s jump on to installing laravel.

Steps to Install Laravel 5.5 on Ubuntu 16.04 with Apache

If you are developing a Laravel application then I will strongly recommend you to develop it using Ubuntu instead of using Windows. Because to be honest you will not learn everything on windows like you do on Ubuntu. And to be fair when you deploy your application on the server it will be Ubuntu, not Windows.

In my case,  I prefer using Virtual Machine to develop an application and here I am using VMWare Workstation to setup the virtual laravel development environment.

You can skip the next step if you are not interested in creating a virtual machine. You can also install it on a physical Ubuntu machine.

Installing Ubuntu on VMWare Workstation

  1. Click Create a New Virtual Machine. Select the Ubuntu iso file. (In my case it was Ubuntu 16.04 x64 64-bit)Vmware Workstation Create Virtual Machine 1
  2. Follow the on screen instructions and enter user name and password for the new Ubuntu Installation.Vmware Workstation Create Virtual Machine 2
  3. Here are the configurations for my Ubuntu virtual machine.Vmware Workstation Configuration
  4. Boot up the Ubuntu and wait for the installation to complete.Ubuntu Login

Updating the Ubuntu OS

Ubuntu Update

Protect Your Online Privacy With Surfshark
[The VPN that we use here at Tech Arrival]

Before we begin installing Laravel it is better to check for updates for modules and Linux distribution.

  • sudo apt-get update to fetch the latest updates.
  • sudo apt-get dist-upgrade to upgrade modules and distribution.

Installing Required Packages for Laravel

There are several requirements of laravel that are listed on the official website of Laravel. But here are all the packages that you will need to deploy a successful laravel installation.

sudo apt-get install php-dev php-mcrypt php-gd php-mbstring php-xml php-common php-zip apache2-dev libapache2-mod-php mysql-server composer npm

Note: During MySQL Server installation you will be prompted to choose a password for the root user. Enter the desired password and remember it because you will need it while creating a connection between the Laravel app and the MySQL server.

The above command will install all of the packages that you will ever need for a Laravel installation. Here is a brief overview about what these packages are for.

  • php-dev: PHP Development Package
  • php-mcrypt: PHP mcrypt to encrypt the data
  • php-gd: It can also be used to create and manipulate image files like GIF, PNG, JPEG, WBMP, and XPM
  • php-mbstring: express more than 256 characters in the regular bytewise coding system
  • php-xml: PHP XML Support
  • php-common: Common PHP Modules
  • php-zip: PHP Zip support
  • apache2-dev: Apache Development Package
  • libapache2-mod-php: PHP Execution
  • mysql-server: MySQL Database Server
  • composer:  Tool for dependency management in PHP
  • npm: Package manager for JavaScript

Installing Laravel

Now you are ready to fire up the laravel installation on your Ubuntu system. Type the below command to get installation started

composer global require “laravel/installer”

Wait for the installation to complete(Here Laravel 5.5). But wait when you type laravel in the terminal you will get command not found error. Here is how to fix that.

  1. Type nano .bashrc
  2. Add this line at top of the file:
    export PATH=”$PATH:$HOME/.config/composer/vendor/bin”
  3. Fire up source ~/.bashrc

Now type laravel in the terminal and boom! you are ready to roll.

Creating New Laravel App

To create a new laravel app you just simply need to type:

laravel new {appname}

Protect Your Online Privacy With Surfshark
[The VPN that we use here at Tech Arrival]

Here we have installed the new app in /home/{username}/{appname}

Now you can fire up the php artisan serve and go to localhost:8000 to see laravel in action. But we are not going to do that because instead of this temporary server we are going to configure apache2 because it is a robust solution.

Laravel Env Error

If you see an error like ‘error something went wrong’ then here is what to do.

  1. Go to the laravel app folder and rename .env.example to .env.
  2. cd {yourapplocation}
  3. Type php artisan key:generate to generate the encryption key for the app.
  4. Reload localhost:8000

If the error is not yet fixed then enable the debug option from {yourapplocation}/config/app.php

Configuring the Apache Server

By default localhost serve /var/www/html. But we want it to display the content of {yourapp}/public content. So we will need to modify Apache Virtual Host file to setup everything correctly:

  1. Open Apache default configuration file by typing: sudo nano /etc/apache2/sites-available/000-default.conf
  2. Change DocumentRoot /var/www/html
    to DocumentRoot /{yourapplocation}/public
  3. Add the following lines below the edited line.
    <Directory /{yourapplocation}/public>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted

If you are using SSL with your server and application then make the same changes in /etc/apache2/sites-available/default-ssl.conf

To make sure that Apache has enabled the required modules for laravel type the commands given below:

sudo a2enmod rewrite
sudo a2enmod php7.0

Laravel App HomepageIt will enable the mod-rewrite and PHP module for the Apache server. Now all you need to do is to reboot the server so that the changes can take place. Type sudo service apache2 restart to restart the Apache server.

Open localhost or to check whether laravel app is working or not.

Protect Your Online Privacy With Surfshark
[The VPN that we use here at Tech Arrival]

Some Extra Things to Take Care Of

Although steps in this section are not necessary. We will highly recommend you to perform these before beginning the development of the application.

Fixing File Permission

If there is ever a permission error fire up the following commands.

sudo chmod -R 755 /{yourapplocation}
sudo chmod -R 777 {yourapplocation}/storage

Updating NodeJS & npm to Latest Version

As far I recall I didn’t have the latest version of nodejs & npm after performing all of the above steps and that caused errors with some dependencies in my project so here is what to do: (This steps will install the latest version of nodejs and npm required for Laravel 5.5)

  1. Remove NodeJS and npm completely using sudo apt-get purge nodejs npm.
  2. Select the Appropriate Node Version and FireUp any of the following three commands:
    sudo curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash –
    sudo curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash –
    sudo curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash –
  3. Install the latest version of both packages using sudo apt-get install -y nodejs npm

Installing Laravel Composer Dependencies

Type the following commands to install and update the composer dependencies of your Laravel app.

composer install
composer update

So that was all. I hope that you got your laravel installation working on the first go. If not the let us know where you are stuck using the comment section below. We would be glad to help you out.

“As an Amazon Associate & Affiliate Partners of several other brands we earn from qualifying purchases.” [Read More Here]

Mehul Boricha
Mehul Boricha
Mehul Boricha is the founder of Tech Arrival & Astute Links. He is a computer and smartphone geek from Junagadh, Gujarat, India. He is a Computer Engineer by Education & an Entrepreneur by Passion. Apart from technology geek, he is an audiophile & loves to connect with people.


  1. This is one hell of an article on laravel.
    Currently, I am running laravel in windows but I am going to give it a try and develop in Ubuntu.
    This clears all doubt on how to install laravel in Ubuntu.

    Thanks for the article.

  2. Are you sure you need to put both nodejs and npm in the sudo apt-get install -y ? I think just nodejs is fine, in fact its an error for me if I tried to install npm like that…

    • Yeah Bengotek, You are absolutely correct. But if you are in development environment then no need to worry.

      Actually today I deployed laravel to production server without performing this step.

      It’s optional. Let me know what you think.

      • I’ve done the apache2 part exactly like you said ( except its php7.1 not 7.0), however when I went to localhost, the default ubuntu welcome page was still shown instead of the laravel page, I’ve changed the 000-default.conf file to:

        #DocumentRoot /var/www/html
        DocumentRoot ~/laravelproject/public

        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted

        I’ve restarted the apache2 service too.

        • That’s impossible. To verify you can go-to var/www/html and modify the index file to check whether Apache is still using that folder or not. I will be able to resolve the problem better if we communicate directly via Skype or something. Skype@borichamehul5

  3. Very nice write up and exactly what I was looking for! Coming from Rails I was looking to some instructions similar to what I used to get Rails up and running, and you my friend have done it! Thanks again!

  4. thanks for the article, it’s very helpful and easy to understand.

    regarding the apache default-conf file, I want to maintain the current document root (/var/www/html) bcoz still got a few other php applications). How should I add my laravel project so it can be access via apache?


  5. I prefer to use Debian over Ubuntu. Ubuntu has great UI but Debian has great community and timely patches. I have hosted my Laravel app on a Debian based server using the Cloudways platform and I have seen slight increase in performance when I moved from Ubuntu. This could be due to some other factor, but who knows.

Leave a Comment

Please enter your comment!
Please enter your name here

By submitting the above comment form, you agree to our Privacy Policy and agree with the storage and handling of your data by this website.

Stay Connected

Subscribe to our Newsletter

Stay updated with all the latest news, offers and special announcements.

By signing up, you agree to our Privacy Policy and agree with the storage and handling of your data by this website.

Latest Posts

12 Best WiFi Hacking Apps for Android & iPhone

Today, almost anywhere we go, we are surrounded by tons of WiFi Networks, whether at our homes, hotels, workplaces, or even public places like...

How to Disable YouTube Shorts Permanently | Top 6 Methods

Since TikTok, short video clips have become extremely popular among social media users. Following the massive success of TikTok, almost all social media sites...

How to Fix “Your Organization’s Data Cannot Be Pasted Here” Error

When copying data across Office Applications on your Windows PC, you might come across the "Your Organization's Data Cannot Be Pasted Here" error message....

How to Install Chrome OS Flex on Windows & Mac Computer

Google announced Chrome OS Flex in February 2022. Before that, only Chromebook users had access to Chrome OS. Users who wanted to use the...

How To Create a Fake Email Address Within Seconds

Using your primary email ID to sign up for web services is never a good idea. Some of these services send dozens of daily...

All Time Favorites

12 Best WiFi Hacking Apps for Android & iPhone

Today, almost anywhere we go, we are surrounded by tons of WiFi Networks, whether at our homes, hotels, workplaces, or even public places like...

21 Best Android Apps Not on Google Play Store

Google Play Store has the most extensive collection of apps for Android. Almost everyone downloads apps from the Play Store. But many excellent apps...

15 Best Game Hacking Apps for Android with/without Root

Are you a mobile gamer? If you are, then you've come to the right place. This post will tell you about the Best Game...

How to Download Torrent Files with IDM (Torrent to IDM)

Hey guys, you may all have heard about different ways to download torrent files. And some of you may also have downloaded them using...

11 Best Download Managers for Windows

The Internet is a vast resource of a lot of things which includes music, videos, movies and a lot of other things. The ability...