[Tutorial] Installing & configuring laravel on shared hosting (Hostgator)

This is my first post in this blog, and I hope you find it useful. Everything you find here has been tested in Hostgator.

As you know Laravel as a great php framework, involves some work when you try to install it on shared hosting. people using Hostgator are very aware of this. Because you first BIG problem is that your php version doesn’t meet the Laravel system requirements which is 5.3.17 or greater. This is one of the problem solved within this tutorial. So lets dive in.

Key points:

  • Upload your files
  • php 5.3 is not used by default
  • Installing composer
  • Install the framework dependencies using composer
  • Where to put things
  • Update your index.php / paths.php files include the correct paths

Uploading your base files

Laravel has been designed so that you can keep your app files out of the public_html folder which adds extra security for your app. So what I suggest is that you create a folder in your root home directory, name it something like ‘app_base’, and put everything in there, assuming you have downloaded Laravel as a zip file from github. We will work on that folder for the next steps.

Your next option is to use git command via ssh. Hostgator has git installed for you.

login via ssh using the command bellow:

ssh -p 2222 [email protected]

Once logged in, and you are in your root home folder, type git just to make sure you have it installed.
Next, clone the Laravel repository in the app_base folder using this code:

git clone https://github.com/laravel/laravel.git app_base

git will start downloading the framework for you.

Once finished, we are ready to install composer’s phar file. getComposer.org has a command line that you can use to download composer.phar into your app_base folder.

curl -sS https://getcomposer.org/installer | php

Obviously this won’t work, composer will tell you that it needs php 5.3.x to work.

PHP 5.3 is not used by default

Hostgator has php 5.3.7 installed on every shared hosting account. but to use it you need to do 2 small changes. The first is to add some code to your .htaccess file, and the second change is to use another command in your terminal to reference php 5.3.

Create an .htaccess file in your app_base folder

Yes you are right, there is no .htaccess in your app_base folder, but we will need to create one and add some code to it.

once created (And don’t forget the dot in front of htaccess), put this code in:

# Use PHP 5.3
AddType application/x-httpd-php53 .php

Using php 5.3

Now your app will be using php 5.3 instead of 5.2. but this is not everything, now when trying to use php in your terminal (or putty or whatever you are using) via SSH, you need to use/opt/php53/bin/php and it will work. Now let’s get back to install composer.

here is a little trick if you want to use php instead of/opt/php53/bin/php, add an alias:

alias php="/opt/php53/bin/php"

Installing Composer

Using ssh, cd into your app_base folder, and install composer using this code:

curl -sS https://getcomposer.org/installer | php


curl -sS https://getcomposer.org/installer | /opt/php53/bin/php

Composer will be installed without a problem if you followed all the steps from the beginning.
do a little ls just to verify that the composer.phar file is there.

Install the framework dependencies using composer

This is the fun part, all you have to do is shoot a composer install on your terminal, and every single package used by laravel will be downloaded and installed for you.

/opt/php53/bin/php composer.phar install


php composer.phar install

If you notice that the last artisan command fails, don’t worry, you can run it yourself after composer is done installing.
The command is simply php artisan optimize

Now you have everything installed. Nothing will be accessible yet from the web. because we still need to move the public folder’s content to the public_html folder, so that you can point to that folder from the web.

Where to put things

Create a folder inside your public_html folder, name it say DEMO. And move the content of your laravel’s public folder into the demo folder.

If you point to the demo folder from the web, it won’t work. this is because you still need to update your paths.php file to include the correct paths to different parts of the application.

Update your public/index.php && paths.php files to include the correct paths

In order for the application to know where your App is, open the index.php file inside DEMO folder you created and change all the paths you find there. You need to provide valid paths to your bootstrap files.

change this:

require __DIR__.'/../bootstrap/autoload.php';


require __DIR__.'/../app_base/bootstrap/autoload.php';

And so on.

Now open your bootstrap folder inside your laravel app, and change the public path inside paths.php

Change this

'public' => __DIR__.'/../public'


'public' => __DIR__.'/../../public_html/demo'

If you got here, everything should work now, point your browser to your demo folder and see if your laravel app boots up with a default view saying YOU HAVE ARRIVED!

I hope this was helpful for you. let me know if you get stuck.


  1. Hi I got error when running the command php composer.phar install

    Problem 1
    – This package requires php >=5.5.9 but your PHP version (5.4.43) does not satisfy that requirement.
    Problem 2
    – laravel/framework v5.1.9 requires php >=5.5.9 -> your PHP version (5.4.43) or “config.platform.php” value does not satisfy that requirement.
    – laravel/framework v5.1.8 requires php >=5.5.9 -> your PHP version (5.4.43) or “config.platform.php” value does not satisfy that requirement.

    Can you please help me.

  2. Thank you for the guidance, I’m stuck for quite sometime and even gave up on configure laravel in hostgator because of their poor supports. I’m currently using php laravel 5, it works well for me! Many thanks!

    1. I think shared hosting is very limited for developers, I suggest that you take a look at Digitalocean.com, you can spin a server for $5/month (very cheap).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.