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

Dibelius's avatar

Issues on deploying Laravel project manually (shared hosting)

Hi there, my question may seem dumb but I was following this video tutorial on deploying my project via FTP just to begin somewhere. https://www.youtube.com/watch?v=6g8G3YQtQt4

Everything worked so far, and when I navigate to my site, it is set up and rendered BUT only for the very first index page. Whenever I click on a navigation link to trigger a route I get an Internal Server Error.

Tested with redirecting immediately which also fails with Internal Server Error

// web.php
Route::get('/', function () {
    return view('home').redirect('/about');
    /* also works, but corrected to
    return redirect('/about');
    as commented below */
});

Applying another view directly works for the main route but still fails when clicking another navigation link

// web.php
Route::get('/', function () {
    return view('about');
});

I edited and reuploaded the remote variant of public/index.php as described but with a slightly different path at vendor (this should be ok?)

require __DIR__.'/../mysite/vendor/autoload.php';
$app = require_once __DIR__.'/../mysite/bootstrap/app.php';

Also the remote .env is updated with DB settings, APP_DEBUG is set to false and APP_ENV to production.

I am surely missing something important. Any suggestions?

0 likes
6 replies
bugsysha's avatar

You can't have return view('home').redirect('/about');. It is either return view('home'); or return redirect('/about');.

Tray2's avatar

There are a few things that needs to be setup correctly.

  • The document root should point to the public directory
  • If you use apache and you can't change the document root make sure you have a htacccess file that redirects all requests to the public directory.
  • Not sure how to acheive that on nginx but it should be possible.
  • You need to have moderewrite enabled if you use apache.
  • Make sure the users can't access the .env file.
1 like
Dibelius's avatar

Thanks guys,

I realized that a few steps could have been simplified. At my hoster's dashboard I simply set the "webspace" path to /mylaravelapp/public while leaving the /mylaravelapp/public/index.php unchanged. The host root directory is htdocs, so to clarify things I've got a directory tree like:

/                            *<abs_path>/htdocs/*
    ...
    mylaravelapp/
        ...
        .env                 *remote production version with DB settings*
        public/              *host webspace points to here (/mylaravelapp/public/)*
            index.php        *unchanged*

However, this does not solve the main problem that navigating on the site causes Error 500. I did not touch composer.json manually, so any require and require-dev setups should be OK.

Could this be caused by wrong remote DB setup also? When I update my main route to fetch the first user in the DB (which was seeded and should exist) and try to display its name or id on the home page, I also run into an Error 500. -- SOLVED

/* This works only locally right now */
// routes/web.php
Route::get('/', function () {
    return view('index', [ 'user' => User::first() ]);
});
// resources/views/index.blade.php
{{ $user->id }}
bugsysha's avatar

If you've set up everything correctly, Laravel should write to /mylaravelapp/storage/logs/laravel.log file where you can see what the actual error is instead of us guessing it. Post the error here for help, or you can fix it by searching it or reading the log by yourself.

1 like
Dibelius's avatar

Sorry, I was simply testing wrong. The database connection works and the user id or name will be displayed now. It is the routing that is still not working. After having a look into the logfile, it seems Error 500 won't be logged, right?

Please or to participate in this conversation.