Installing Laravel 5.2 on Ubuntu 15.10 and Apache2

First off, I’d like to mention that there is a “highly recommended” virtual machine that comes with Laravel itself. So perhaps you really should be using that.

Moving on…

Install PHP and required extensions

Minimum requirements for your PHP installation are as follows:

  • PHP >= 5.5.9

Check this by going to the command-line and doing:

  • OpenSSL PHP Extension
  • PDO PHP Extension
  • MbString PHP Extension
  • Tokenizer PHP Extension

Use the following command to check your installed extensions:

Installing Composer

Laravel also uses Composer so install that by using the following command:

Note that this is for a global install. If you want to install it locally, just follow these instructions.

Get Laravel and Add To PATH

Let’s use Composer to download the Laravel installer:

Then add it to our PATH, so that we can call the Laravel executable from anywhere:

If for some reason your installation doesn’t have ~/.bashrc , you can use  ~/.bash_profile  instead.

Now in order to create a new Laravel project, just use the  laravel new command, followed by the directory name. For example,  laravel new monkey  will create a new laravel project, in the directory  monkey

Laravel Configuration

The minimum amount of configuration that I had to do before I was able to get the Laravel 5 logo to show on my browser was to make the  storage  and bootstrap/cache  directories are writable by Apache.

Don’t forget to change the “monkey” directory to whatever you called your project earlier.

 

Apache Virtual Host

There are numerous ways of setting up the Apache2 Virtual Host and one must be careful about which guide to follow, as the exact method is changed (slightly) over the course of Apache updates. The following steps are what I did to get it working on my clean Ubuntu 15.10 installation. YMMV (Your Migraine May Vary).

First thing to do is to create a copy of the default host:

Then open the new file with your favorite text-editor (using sudo):

I have removed all the comments, but this is what you want to end up with:

Enable this new virtual host, and disable the default one.

Then restart Apache

Loading the page with a web browser should now proudly display the Laravel 5 logo.

*high-fives all around*

But wait, belay that order! Since most (if not all) of the projects I work on require some sort of user authentication, I am going to add instruction for it to this post (and link back to it ad infinitum).

To get Laravel to build user registration, and authentication, run this code, at the root folder of your project:

Refresh the browser and you will see that the home page now has a working log in and registration page.

Now it’s time for the high-fives….*sniff* so proud…

This entry was posted in Dev, Laravel, PHP. Bookmark the permalink.

Leave a Reply

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