Setting up Laravel 5 on Digital Ocean Ubuntu Apache


Hello, I am assuming you already have digital ocean account and your droplet. Here are the prerequisites:

  • Ubuntu 14.04
  • LAMP installed
  • You have SSH access

To check once that LAMP is installed and running, you can open the default page of the server by typing the IP address. You should see a default page from Apache. If you see it, great. Let’s get it rolling and in next 20 minutes you will be able to installe everything needed to get your Laravel 5 app up and running.


Step 1: Install Composer

Composer is a dependency manager for PHP. It’s great tool to setup libraries and automatically resolve dependency on the fly. I recommend using it even when there are no

Now when composer is installed it will produce a file named composer.phar. Phar is nothing but a PHP archive. You need to move this file to a place from where it’s accessible globally.


Note: You might need to update permissions of the folder. It works perfectly fine on the droplet with Ubuntu image but it may require permission. Just use chown and or chmod to change permissions or ownership.

Step 2: Install Mcrypt Extension


Laravel 5 requires mcrypt php extension installed. Please follow these steps to setup mcrypt and have Apache load it. Type following commands to update DB and find mcrypt installation.

Should show it located at /etc/php5/mods-available. Now let’s locate the extension file

Edit mcrypt.ini and change extension to match the path to mcrypt.so, example:

Now this:

Verify that new files exists here (they should be auto created from the issue above)

Otherwise do the following

Create symbol links now

Restart Apache

  Step 3: Setup Laravel 5

Now we are ready to setup Laravel 5. Please note that Laravel runs from public folder which makes it little tricky to setup as compared to other php applications.

Install Laravel 5 in /var/www/folder

Install Laravel 5 using composer create-project command.

This will create a folder laravel in your /var/www/. Now we have to move the contents of public folder from within laravel to /var/www/html/ folder. After that please edit index.php file to point to correct path for autoload.php. There are 2 lines you can easily find and edit the path with ../laravel to point it correctly to laravel folder.

Step 4: Enable Apache mod_rewrite

Apache uses mod_rewrite to make pretty URLs work. By default it’s disabled on the Apache so we need to enable it to get our app work properly.

Restart Apache


Step 4: Change Permissions

You might need to change permissions of the www folder to make it work. It is required if your application will be uploading files and storing on server etc.

Related Posts

About the Author: