Deploy Laravel 5 on GoDaddy Shared Hosting

Note: I originally wrote this article on Medium.

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:

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.

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

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

require __DIR__.'/../bootstrap/autoload.php';
$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.