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

stufflh's avatar

Error 500 in laravel on shared hosting

I tried to deploy my Laravel app [PHP 8.3.12 — Laravel 11.36.1] to shared hosting, and I see a 500 Internal Server Error message on the website the message is not comming from laravel but from browser browser error :

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at your hosting provider to inform them of the time this error occurred and the actions you performed just before this error. More information about this error may be available in the server error log. I moved all files in the public folder to the public_html directory.

In my first attempt, I moved the other files to a folder inside public_html. In my second attempt, I moved all other files (except the public folder) to a folder one level above public_html. In my third attempt, I moved everything to the public_html directory.

I modified the URLs in 'bootstrap/app.php', 'vendor/autoload.php', and 'storage/framework/maintenance.php'. to point to the location of these files aeahc time I try

I modified the .env file to use the hosting database instead of my local database and changed other settings, such as the type of app from local to production and the localhost URL to my website URL. This is all standard stuff that can be found in tutorials the stupid AI bots suggestions... don't provide much help.

I didn't change anything else. I used my project that I was working on for a while locally, but when it didn't work, I just used a fresh Laravel app without any modifications. I installed Laravel Breeze and deployed it to that shared hosting instead of my project, but I encountered the same problem: a 500 Internal Server Error.

What could the problem be? Any suggestions, ideas, or anything would be appreciated.

Note: The hosting provider has a one-click install feature, which I used to install Laravel on the website. It works, but when I go to the public_html directory, I see an index.php file that doesn't contain any PHP code—just a simple HTML file with some styles, an H1 tag, and a paragraph. There is also a "laravel11" folder inside it, which contains all the Laravel files and folders, including the public folder and everything else. but I've never know this structure what I know for deploy laravel is to set the public content in public_html and other files to separate folder one step above the index.php file for secutiry and all that stuff

In the .env file, I found settings like APP_ENV=local and all the default settings that come with a fresh Laravel installation. One thing I tried was to copy my entire project into the "laravel11" folder to replace those default files with mine. After doing this, the website worked, and I could see the login page, but there was no styling on the page.

When I logged in, I received an error stating that the view was not defined, even though the views folder is in the correct location with all the files present. Everything is there, just as it is in my local environment. I removed everything and started again with the previous method, but there was still no result.

0 likes
4 replies
stufflh's avatar

@jlrdw I solved that my project was fine the problem was in the hosting it self the hosting was providing a one click insatll feature I used it and then opened file manager and removed the insatlled version and deployed mine then it was problem I uploaded the laravel to fresh new hosting and then eveyrthing works well

stufflh's avatar

@jlrdw I solved that my project was fine the problem was in the hosting it self the hosting was providing a one click insatll feature I used it and then opened file manager and removed the insatlled version and deployed mine then it was problem I uploaded the laravel to fresh new hosting and then eveyrthing works well thanks for your help 🙏

martinbean's avatar

@stufflh As others have said, you don’t want everything sitting in your public_html directory. It should be one level up.

If you’re stuck with public_html being the name of your publicly-accessible directory, then you can rename the public directory in your codebase to be public_html and then instruct Laravel to use that as the name of its “public” directory.

In your bootstrap/app.php file, after the create method call, you can chain usePublicPath to specify the alternative public path:

// bootstrap/app.php
return Application::configure()
    ->withExceptions(function (Exceptions $exceptions) {
        // ...
    })
    ->withMiddleware(function (Middleware $middleware) {
        // ...
    })
    ->withRouting(function () {
        // ...
    })
    ->create()
    ->usePublicPath(dirname(__DIR__) . '/public_html'); // Use public_html instead
1 like

Please or to participate in this conversation.