5

I'm running my laravel site in my localhost, works fine. But when I try run my site in hosting server, I got 500 internal server error? Is it because of my .htaccess file or I remove public url ?

My .htaccess file

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Nurdin
  • 23,382
  • 43
  • 130
  • 308

4 Answers4

2

Try this on the terminal :

sudo chmod -R 755 <your_laravel_project> 

and

chmod -R o+w <your_laravel_project>/storage
Hanson
  • 99
  • 8
Arunabh Das
  • 13,212
  • 21
  • 86
  • 109
0

Make sure you're using a supported version of PHP and that your folders have 755 permission.

You can also check the Laravel's log file to learn a bit more about what caused the 500 error. If there is no entry in the log file, the problem might come from the .htaccess.

FrancoisBaveye
  • 1,902
  • 1
  • 18
  • 25
0

I ran into a similar problem with my shared hosting provider. Laravel uses the public folder for files that are directly accessible for the visitors browser. This should be the webspace root on the shared hosting.

The problem occurs, when the index.php in /public is called and it tries to access files outside (a level above) the webspace root. Normally this is not allowed.

You (or your hosting provider) need to change the open_basedir value in php settings.

On my hosting it looked like this:

{WEBSPACEROOT}{/}{:}{TMP}{/}

I changed it to

{WEBSPACEROOT}{/}{:}{TMP}{/}{:}{WEBSPACEROOT}{/../}

and it worked.

user3190433
  • 375
  • 3
  • 7
0

Try following commands one by one. I hope my solution will solve your problem.

find <laravel_project_path> -type d -exec chmod 755 {} \;

find <laravel_project_path> -type d -exec chmod ug+s {} \;

find <laravel_project_path> -type f -exec chmod 644 {} \;

chown -R www-data:www-data <laravel_project_path>

chmod -R 777 <laravel_project_path>/storage

chmod -R 777 <laravel_project_path>/bootstrap/cache/

find <laravel_project_path>/vendor -type f -exec chmod 664 {} \;
Dasun Tharanga
  • 163
  • 1
  • 11