Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cabillier's avatar

Deploying L5.1 to production on a shared hosting

I need help in pushing my laravel app to a production server...

this the structure of my hosting site...

/home/user/

inside this folder is my laravel project, public_html and other files

i copied my public folder inside public_html... and changed the 2 lines of codes in index.php so that it will reference the correct files inside laravel app... but i can't seem to get it working...

please help...

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylorotwell@gmail.com>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
*/

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

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
*/

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

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

I get 500 error response

0 likes
2 replies
jlrdw's avatar

Seriously if you search the forum this topic has been answered probably 200 times.
https://laracasts.com/search?q=Deploy&q-where=lessons and https://laracasts.com/discuss/channels/laravel/env-file and also found THE GUIDE that's referred from laravel news: https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e and another technique from stackoverflow that works a little different, but does work: http://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url

kieranjfahy's avatar

If they allow git on your shared hosting and you use it, I would highly suggest you do it that way. I wasted lots of time on FTP, trying to remeber what files I'd changed etc.

Git pull Composer install Migrate Etc

The other thing I would suggest is use a symbolic link and link the public folder that way, remember when you create the link, don't have the foder created in the public_html folder. The big benefit of doing it that way, is, when you ssh into the server and you do a git pull, it updates all the public directory and you don't have to mess around copy and pasting/ moving files to your directory in the public_html folder.

This setup works for me!

Please or to participate in this conversation.