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]


  1. 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.

  2. 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?


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

Effective Strategies to Secure Your Cloud Infrastructure and Safeguard Your Business

Cloud computing is an essential element in modern businesses due to its scalability, flexibility, and cost-effectiveness. With the widespread adoption of digital transformation, security...

10 Best WhatsApp Privacy Settings to Protect Yourself (2023)

WhatsApp has recently introduced many features to safeguard its users from SPAM and Illicit activities. Some of these features are turned on by default,...

Can You See Who Screenshotted Your WhatsApp Status?

From hiding your profile picture to limiting your audience for status, WhatsApp has introduced many features to increase the privacy level of the app. Like...

How to Automatically Spin Down or Sleep HDD on Debian

It is probably not a great idea to let your HDD spin forever on a server that is always on. Whether you are using...

What is the Black Spot on Phone Screen & How to Fix It?

Smartphone screens are delicate and can get damaged easily. One common issue smartphone users face is the black spot on phone screen. A black spot...

All Time Favorites

11 Best WiFi Hacking Apps for Android (2023)

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

17 Best Illegal Android Apps Not on Play Store (2023)

Google Play Store has the most extensive collection of apps for Android. Almost everyone downloads apps from the Play Store. However, certain genuinely excellent...

15 Best Game Hacking Apps for Android (2023)

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...