Deploying Laravel 5 on GoDaddy Shared Hosting

Kunal Nagar
Jan 8, 2015 · 2 min read

So your awesome project is ready for deployment and you need to set it up on GoDaddy shared hosting servers.

Requirements

Here are some things that you need before we get started:

  • A GoDaddy shared hosting account
  • SSH access
  • Awesome Laravel Project to be deployed

Steps

Before we start, let’s assume that your home directory on the server is

/home/content/kunalnagar/html

and all your code goes into the html folder.

  • Create a folder on the same level as the html folder to hold your future Laravel installations. It’s just good practice.
  • Connect via SFTP to your shared hosting server.
  • Zip your entire project directory and upload it to the new folder you just created. Unzip it.
  • Move the public folder into the html folder and rename it to something like awesome-project.

The approach mentioned above makes all of our application logic safe and our public folder is the one that is exposed.

But we're not done!

Open up the index.php file and change the paths to reflect our new directory structure. Here are the following lines you should change:

Autoload file path:

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

App path:

$app = require_once __DIR__.'/../bootstrap/app.php';

Finally, we modify the main .htaccess file in the html directory. We do this so that you don't have to type:

http://yoursite.com/awesome-project

Here are the contents of the .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome-project
RewriteRule ^(.*)$ awesome-project/$1 [L]

And you’re done! Try visiting:

http://yoursite.com

and enjoy your awesome new project.

Please note that this article only discusses deploying the project files. If you need to deploy your migrations, there are tons of articles that you can look up. The confusing part is setting up the directory structure and this article covers that point.

For more articles, check out my website: http://kunalnagar.in/

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade