Install Laravel 4.2 on Ubuntu Server 14.04 LTS

I was having a little trouble getting Laravel installed on a newly installed Ubuntu 14.04 LTS server. I’ve decided to document the whole process in hopes that I’ll use the documentation to good use once again sometime in the future. Who knows, someone will benefit from reading this. I’m not the only one that will be doing a Laravel installation on Ubuntu.

If you need to install Ubuntu from scratch, I recommend that use install LAMP and SSH because you’ll need those services to support Laravel. PHP, MySQL, Apache and SSH would be installed for you right out of the gate. In addition, I recommend that you install PHPMyAdmin for database administration.

# Install Tasksel
sudo apt-get -y install tasksel
# Install LAMP
sudo tasksel install lamp-server
# Install PHPMyAdmin
sudo apt-get install phpmyadmin

In Ubuntu, the default document root is /var/www/. Before starting, let’s make sure we got the correct permissions for Apache, and for the user (you). This is to prevent so you don’t run into issues with write permissions on the document root.

Permissions for /var/www/

# Set group to www-data
sudo chgrp www-data /var/www
# Make it writable for the group
sudo chmod 775 /var/www
# Set GID to www-data for all sub-folders
sudo chmod g+s /var/www
# Add your username to www-data group
sudo usermod -a -G www-data username
# Finally change ownership to username
sudo chown username /var/www/
# Your account shouldn't have any more permission issues

Let’s get the prerequisites taken care of before installing Laravel

Install Curl

sudo apt-get install php5-curl

Install Mycrypt

sudo apt-get install php5-mcrypt

Activate Mcrypt

# Enable extension
sudo php5enmod mcrypt
# Restart Apache
sudo service apache2 reload

Enable Mod-Rewrite

# enable rewrite
sudo a2enmod rewrite
# restart apache
sudo service apache restart

Install Laravel via Composer

Install Composer First

cd ~
curl -sS | sudo php

Installer Composer Globally

sudo mv composer.phar /usr/local/bin/composer

Install Laravel

# your-project is your destination folder
cd /var/www/
composer create-project laravel/laravel your-project --prefer-dist

Set up your Apache virtual host

# Copy default Apache conf
sudo cp /etc/apache2/sites-available/000-default /etc/apache2/sites-available/laravel.conf
# Edit laravel.conf and change DocumentRoot to /var/www/laravel/public
sudo nano /etc/apache2/sites-available/laravel.conf
# Edit laravel.conf add the following and save.
DocumentRoot /var/www/laravel/public
<Directory /var/www/laravel/public>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
# Reload Apache
sudo service apache2 reload
# Disable default Apache conf
sudo a2dissite 000-default.conf
# Enable laravel.conf
sudo a2ensite laravel.conf
# Reload Apache
sudo service apache reload

The cool thing about this example is, by setting up your /var/www permissions, you don’t need to change permissions to “app/storage” since you already have the correct permission to /var/www.

Finally, access Laravel from the IP address of your Ubuntu Server. The IP address of your Ubuntu server should be a static IP address. You can set this in the network config file called /etc/networking/interfaces.

Have fun!

Default Virtual Host in Apache

If you have multiple domains installed in a virtual host configuration with one IP address in Apache, the IP address may not resolve to the domain you prefer. Let me explain.

For example, you have the following domains running on an Ubuntu Server with one IP address.

All the domains are resolving as expected on the browser.

However, if you type the IP address on the browser, it only defaults to the first domain found in the /etc/apache2/sites-available directory, which is most likely

If you want the IP address to default to another domain, such as for example, you will need to edit the /etc/apache2/httpd.conf file and add the following entries.

<VirtualHost *:80>
DocumentRoot /var/www/

Those are the only entries you’ll need. Typing the IP address on the browser will now default to the contents of All the other domains are still accessible via domain names on the browser.

Simple Invoices 500 Internal Server Error

Simple Invoices is a free, open source, web based invoicing system that you can install on your server, desktop, or at a service provider. I installed Simple Invoices on a webhost company I rather not mention. The application was working fine, until they tweak their PHP settings several months back. As a result, the PDF export in Simple Invoices no longer worked. I was bummed. So, I was forced to run Simple Invoices from my home server, which was fun, but the issue was, I can’t access it outside of the house.

So, I decided to install Simple Invoices on my new account at Linode. Now, the funny thing was, the application won’t even come up. Not even a login page. So, I searched online for a possible solution to my dilemma. Some suggested to increase the php memory settings to 128M, but that didn’t work out for me. At one time, I thought I had a missing pdo_mysql module, but that wasn’t the case. Then, I stumbled into something that led me to the ultimate discovery.

Simple Invoices has this configuration file called config.ini located inside the config folder. One thing this application doesn’t like are extra characters inside the config file. I happen to like funky passwords with interesting characters like +-)!@#. My MySQL password happens to have a close parenthesis in it. Essentially, this extra character caused the entire application to not start. So, I change my password, and sure enough, the application worked.

So, if you ever get a 500 internal server error with the Simple Invoices application, make sure you don’t have any of those extra characters inside your config.ini file. I wasted two hours trying to fix this issue, only to be surprised by such an idiotic requirement. That means I can’t use difficult passwords for this application. I think this is either a design issue or a funny requirement of the Zend Framework, which by the way, Simple Invoices is written on. It was somewhat funny, but I wasn’t amused.

Permissions To Webroot

I was wondering about the best way to implement and give permissions to webroot, also known as the root directory of your web server. I’m familiar with Ubuntu’s structure, so I’ll use Ubuntu’s default webroot directory, which is /var/www.

Based on numerous documents and discussions I’ve read online, the proper way to give permissions to webroot is to (1 ) add a user to the www-data group, (2) change webroot’s ownership to www-data, (3) give all members of www-data group read and right access.

ulysses = user
webroot = /var/www
www-data = user and group for Apache

Here are the commands to run from the Terminal.

Step 1

Add new user to the www-data group.

sudo adduser ulysses www-data


Add existing user to the www-data group.

sudo usermod -a -G www-data ulysses

Step 2

Make www-data the group owner of /www/data

sudo chown -R ulysses:www-data /var/www

Step 3

Give members of www-data permissions.

sudo chmod -R g+rw /var/www

That’s it. Pretty straightforward.