1
votes

I have an laravel app working fine on my local machine. I have just transferred it to my server (Shared hosting) and put everything on a public folder in public_html and everything else in one step above public_html. The problem is now it shows 500 internal error on every route. I have changed .htaccess code to given code on documentation, folder rights to storage and bootstrap are set to 777.

Nothing in error logs and also nothing in laravel log files. when I installed fresh laravel installation it worked on the server as well. Tried updated code with my project but still 500 internal error.

3
please check your storage log file.Akash Kumar Verma
try to change the public path of the application. Check your server.php fileWellwisher

3 Answers

2
votes

If you are using IONOS (or 1and1, maybe works fot other too...), the .htaccess file should be different from the default in laravel public directory.

Replace its content with this:

RewriteBase /

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
1
votes

For Laravel 8 / IONOS Managed Server this works for me:

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

    RewriteBase /
    Options +FollowSymLinks
    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
0
votes

The error may be due to the configuration of .env file.As your question is not clear enough. so i wil explain 2 methods

With vendor and .env file (Not Recomended) - Unzip the main zip file and upload your public_html folder ( upload vendor folder as well)

Give 777 recursive permission to storage/ and bootstrap/ folder

Create database in phpmyadmin and import .sql file

Set Database in .env file

Now normally for all shared hostings you will have jailed SSH you can contact the hosting provider to get its details.

Once you get access , use command

php artisan cache:clear
php artisan config:clear
php artisan config:cache

The file itself can be found in bootstrap/cache/config.php.

Note that the location of the compiled config file has changed recently. Yours might also be in vendor/config.php or storage/framework/config.php. With a fresh install or if you run composer update the file should be in bootstrap/cache though.

Now Directly from GIT or other Sources without Vendor(Recommended)

Make sure you copy all of the project files including the hidden ones(.env).

if You are using GIT use GIT clone to clone the project.

Check you have all the necessary PHP extensions available in php.ini as in Laravel requirements. Also, watch your PHP version!

Install composer https://getcomposer.org/doc/00-intro.md

When copied, go to your destination folder and run composer install.

Run php artisan key:generate from the command line.

then Run

php artisan cache:clear

php artisan config:clear

php artisan config:cache

http://php.net/manual/en/install.windows.commandline.php

Make sure your webserver is serving pages from project/public folder.

Even after completing these steps if Laravel is still showing error, check your_project/storage/logs/laravel.log