Laravel 5 is not working on shared hosting

12,259

Solution 1

I have referred this link laravel.io

Finally, I did the job on my shared hosting. This is what I did

  1. Setup a project Laravel 5 in localhost correctly configured
  2. Double check the server configuration of PHP 5.4 (this because every little change on .htaccess file may change that config)
  3. Create a directory in the same level of public_html and put the project inside of that folder.
  4. Put the content of public (L5) directly on public_html (be aware of don't overwrite the .htaccess file accidentally)

Now... This is the "tricky part"... I see this structure

mail

perl5

php

public_html

[framework-folder]

ssl

Inside of public_html I can see all the files of public directory of Laravel 5 Go to index.php and edit the line 22

From this require __DIR__.'/../bootstrap/autoload.php';
To this require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';

And the line 36

From this $app = require_once __DIR__.'/../bootstrap/app.php';
To this $app = require_once __DIR__.'/../[framework-folder]/pulcro/bootstrap/app.php';

The final step is to edit the .htaccess file and add some lines

RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ /$1 [L]

and update [framework-folder]/server.php

From this require_once __DIR__.'/public/index.php';
To this require_once __DIR__.'/public_html/index.php';

Refresh the cache of my browser and.. Victory!! I know that this is not the absolute right way to install the framework (God, I never spoke about Composer) But... It's working for me now Hope that this can help somebody in order to deploy Laravel 5

Solution 2

thanks to Neeraj Rathod, but I found this article more useful, and of course simple more!

WHY AM I GETTING A 500 INTERNAL SERVER ERROR MESSAGE?

in my case, by reading that article I found out from my "error pages" that the "group writable" permission must not be set for "index.php" file inside "public" folder and also for all folders through route. also you have to check that your shared hosting php version is more than 7.0

Share:
12,259

Related videos on Youtube

Neeraj Rathod
Author by

Neeraj Rathod

Updated on June 04, 2022

Comments

  • Neeraj Rathod
    Neeraj Rathod almost 2 years

    I have tested my Laravel 5 project on localhost its working fine with this url - http://localhost/project-name/public/

    Then I uploaded my project on shared hosting, I have made desirable changes for database on .env file then trying to access it with the url - http://companysite.com/folder/innerFolder/public/

    but not working and getting 500 internal server error

    I have gone through with other questions with the related but no answer lead me to my solution. I have done following steps

    • upload my project on root directory parallel to public_html
    • update to project/public/index.php
    • try to create subdomain pointing to my project but didn't succeed

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator at [email protected] 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.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    • Mjh
      Mjh over 7 years
      You have to read what is in your web server log file. It contains information about what went wrong. Maybe it's a missing extension, maybe it's wrong PHP version, maybe it's something else. Ignore these stupid chmod 777 suggestions, anyone who suggests that should reconsider their career as programmer, you people are really terrible developers if the solution is chmod 777 instead of reading what the web server log says.