Configuring GoDaddy’s shared hosting for Laravel 5 and Git

This post shows how to configure a GoDaddy shared hosting service (hosting Linux with cPanel) for a Laravel 5 application using Git for deploying the code.

Take a look to this other post for general methods about deploy Laravel on shared hosting services: Deploy Laravel Application On Shared Hosting.

1. Configuring SSH and Git

Enable SSH: from cPanel go on Security > SSH Access > Enable SSH, then import your public key.

Check the SSH connection:

# From your local pc 
$ ssh [godaddy-user]@[]

where [godaddy-user] is the username configured for your GoDaddy’s cPanel and [] is the site domain name.

Check that Git is correctly installed on GoDaddy:

$ # From the GoDaddy host 
$ git --version

Create the bin directory on the user’s home:

$ # Always from the GoDaddy host
$ mkdir ~/bin

2. Check the PHP version

Open an SSH connection with GoDaddy, then:

$ php --version

Should print something like:

  PHP 5.5.24 (cgi-fcgi) (built: Apr 20 2015 06:24:55)

Check that the php version is correct (for Laravel 5.1 must be greater than 5.5.9).

Troubleshooting: wrong php version

Can happen that you have setted the newest PHP version from cPanel but via SSH you still have an old version.

If the PHP version is wrong, for example is 5.4.43 instead of 5.5.24, make sure you have changed it in cPanel (in Software > Select PHP Version) then try with:

$ /opt/alt/php55/usr/bin/php --version

If the path /opt/alt/php55/usr/bin/php print out the correct version then set it as your php default command:

$ cd
$ vim .bash_profile

In the file .bash_profile change the row




That is: prepend your local bin directory to assign it the first priority.

Create a link to the right php version:

$ cd bin
$ ln -s /opt/alt/php55/usr/bin/php

Close and reopen the ssh connection and check now the php version.

3. Create the application folder

From GoDaddy host, create the [app] folder in your home, where [app] is the name of your Laravel application:

$ cd ~
$ mkdir [app]

This folder will contains your application.

Depending if you want to install the application in the main domain, e.g., or in a subdomain, e.g. http://[app], do one of the following.

Main domain

Replace the public_html folder with a symbolic link to [app]/public (be sure public_html is empty before delete it):

$ rm -r public_html
$ ln -s [app]/public public_html


Create a sub domain in GoDaddy


access the cPanel at the url http://[]/cpanel then go on Domains > Subdomains > Create Subdomain and insert:

  • Subdomain: [sub-domain] (e.g. app)
  • Document root: /[app]/public

4. Get Composer

From GoDaddy host:

$ # Install composer
$ cd bin
$ curl -sS | php
$ ln -s ./composer.phar composer

5. Configuring Git for automatic deploy

Create the Git bare repository on the GoDaddy’s host:

$ # Create the git directory where the repository will be mantained
$ cd ~
$ mkdir git

$ # Create the repository
$ cd git
$ git init --bare --shared [app].git

$ # Create the post-receive hook file
$ cd [app].git/hooks
$ touch post-receive

$ # Make the hook executable
$ chmod +x post-receive

$ # Configure the hook
$ vim post-receive

Write in the file post-receive all the operations that will be performed after the push is done:


# Set up our PATH variable and export it
export PATH

# App directories

# Checkout the last commit inside the web app directory
git --work-tree=${APP_WEB_DIR} --git-dir=${APP_GIT_DIR} checkout -f

# Clean the app directory
# Use -e "[pattern]" to exclude some file or directory to be cleaned,
# as they are in the .gitignore file
# git --work-tree=${APP_WEB_DIR} clean -fd

# Run composer
composer install
# Ensure that storage's folder have write permission for the group
chmod -R g+w storage

# Optimizations
echo "Running optimizations"
php artisan config:cache
php artisan route:cache

# Do other things here, for example load database changes automatically
# php artisan migrate
# ...

6. Add the ‘production’ remote in your repository

From your PC:

$ # Go in the project's folder
$ cd /path/to/your/project
# Add the 'production' server's URL
$ git remote add production ssh://[godaddy-user]@[]/~/git/[app].git

Now you can deploy the project on GoDaddy (pushing it on the production remote) with:

$ git push production master

You should now be able to see your code on the folder ~/[app] on the GoDaddy’s host.

After configured the database in the host and configured your application (for example you have to create the .env file in the host and set here the db connection parameters) you will be able to access your application from your domain.


  • Shane

    Nice tutorial.. I’m still waiting to see if it works.
    It’d be nice to have some more specific instruction on what to do with the .env file.

    • It works for sure! 😛
      However thanks for your suggestion. I will try to add something more about .env file.

      • Shane

        It seems I made a mistake in my post-receive when pushing to production, therefore the files didn’t move over to my public_html folder.. is there a way to push the files there without having to redo the whole process?

        • You can try to fix your post-receive file then re-try with git push production master.

          Otherwise you can try to log in in your server via ssh, then type:
          git --work-tree=/home/[your-user-name]/public_html --git-dir=/home/[your-user-name]/git/[project-name].git/ checkout -f

          This should copy your code from the repo to the public_html folder.

          • Shane

            Perfect, thanks for all your help and for the tutorial. Works great!

  • Pratyush Barik

    I was trying to get around this. I couldn’t find where the php 5.5.25 binary was. Thanks to you. Great job. 🙂

  • Thank you so much! you are a life saver!

  • J. Fernando Galvez

    hi i follow step bu step the tutorial…!! but when i wanna make push to mi local source to the server show only

    error: inflate: data stream error (incorrect header check)

    error: unable to unpack c0363a9361af8a09a73f7126d35b2c419dcf1964 header

    error: inflate: data stream error (incorrect header check)
    fatal: loose object c0363a9361af8a09a73f7126d35b2c419dcf1964 (stored in .git/objects/c0/363a9361af8a09a73f7126d35b2c419dcf1964) is corrupt
    fatal: early EOF

    someone can help me….

    • Hi Fernando, looks like you have your git repo corrupted:

      You can try to delete the git repo you have on godaddy and recreate it, or delete your local repository also then clone it again from you “origin” remote.

      • J. Fernando Galvez

        thk…. but i cant achieve remove … :'( a tutorial link please like this.. step by step please.!!!

      • J. Fernando Galvez

        thk..!!! i solve the problem.. .. but yi loose all my history to my commint and start from 0 but now works.. fine thk a lot.!!

        • Nice! I’m glad to hear you solved the issue.

  • J. Fernando Galvez

    nice… tutorial.!!! .. now i have a question.. if i wanna multiple users.. how add a new user to my repository … thk.

    • With GoDaddy you have just one ssh user. But you can import another ssh key inside GoDaddy enabling the access to another person also.

      • J. Fernando Galvez

        how i can do that.. please…!! i can’t make that….

        • Are you able to open the ssh connection with your service? Using this:

          ssh [godaddy-user]@[]

          • J. Fernando Galvez

            if i use that commando i enabled another user ??? or how i can add the new user… actually only can make commit for one user, or need a special account ?

  • claide

    Hi, I tried above tutorial but when I go to my site it says:

    The page isn’t working is currently unable to handle this request.
    HTTP ERROR 500

    Any idea? THanks

    • claide

      I think something’s wrong with the linked folder? I removed the public_html then did the
      ln -s [app]/public public_html

      • Hello. The 500 server error is quite generic and it could be due to a lot of things. Do you have some more info or logs about the error?

        The link command should be ok. Did you replaced [app] with your app name? Also be sure that the folder containing your app exists when you create the link.

        • claide

          Hey Andrea, i’m sorry i was mistaken on my the remote production add command. I forgot to add my app.git on the very last. All is good and running now. Thanks great tut by tye way.

          • Ok, great. I’m glad to know it works.


Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow


Developed and designed by Netgloo
© 2016 Netgloo