The simple guide to deploy Laravel 5 application on shared hosting

Pete Houston
Apr 6, 2015 · 3 min read

by Pete Houston

For more about deploying a Laravel/Lumen application on shared hosting, check out my complete guide,


  • 12/Jun/2015: Adding symlink as response from @rverrips, add optimization command for production environment pointed out by @constb.

In this tutorial, I’d like to show you a very simple method to deploy Laravel 5 applications, safe & secure.

First, let say in your hosting server (VPS, or shared hosting…whatever), you have current www/ directory, which is accessible publicly via web domain, for example:

Now, create a new directory, which contains all your application source code, at the same level as www/, for example:

You can use git, svn, mecurial or whatever method you like to transfer your code to this directory.

At this point, you can see that the project code is apparently not accessible to the web, right?

Next step is to copy all contents inside the /project/public directory to www/ directory. The easy example is that, with the fresh Laravel 5 installation application, the project/public/index.php should be copied to the www/index.php , have you got the point?

Remember to copy the public/.htaccess to the www/ also. Don’t forget this, it is very important for your app routes. Without it, your routes won’t be working and there will be a blank or empty page in every route.

Now let’s modify the www/index.php to reflect the new structure. Don’t modify the project/public/index.php, okay? Only modify www/index.php, remember this!!!

Find the following line

And update them to the correct paths as following

It worths to mention that some shared hosting service providers allow symlink to the public_html directory of the main domain, we can simplify the process, instead of copying the whole project/public/ to /www, we create symbolic linking,

Almost done, it is time to set permissions for the project/storage directory, it should be writable.

The final step is here, config your application variables in the project/.env .

All righty right! Everything should work now.

If you don’t have composer installed already on your server, you can easily grab it to the project directory then.

Now you can execute composer to manage dependencies.

From now on, each time you deploy, I mean you update the project/ directory, you will need to reflect all changes in project/public/ directory into www/, except the www/index.php, which is already configured above to include the correct paths.

You can easily achieve this via bash shell command line. I wrote this little script, you can use this by putting into the same directory level with project/ and www/

That’s it. Well then, have fun ☺

Laravel News

News and information about the Laravel PHP framework.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store