4

I already upload my laravel project folder into cpanel hosting. I did't have VPS. I has read many example in laracast and stackoveflow, but still get this 500 internal error. This is my setting.

I has separated public folder in my laravel project and put the other in root directory of my hosting like this.

|-- my_other_folder_project/
|-- [some other folders...]
|-- public_html/ 
|   |-- [some other folders...]
|   |-- my_public_project/

And Change index.php setting into :

from

require __DIR__.'/../vendor/autoload.php';

to

require __DIR__.'/../../my_other_folder_project/vendor/autoload.php';

And From

$app = require_once __DIR__.'/../bootstrap/app.php';

to

$app = require_once __DIR__.'/../../my_other_folder_project/bootstrap/app.php';

I has create .htaccess file for public folder like this :

DirectoryIndex index.php

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

    RewriteEngine On

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

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

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

My PHP for this is 7.1 and I've checked other requirenment like OpenSSL, PDO, Mbstring, Tokenizer Already installed.

But Still get this 500 internal server error, I've searching many refference for this but pointed to the step I've already do.

4
  • 1
    have you checked any logs to see what the 500 error is actually caused by?
    – lagbox
    Dec 13, 2017 at 3:15
  • this is in error_log : [13-Dec-2017 03:20:30 UTC] PHP Parse error: syntax error, unexpected '?' in /home/myuser/myfolder/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233 Dec 13, 2017 at 3:22
  • 4
    That means you don't have PHP 7.1 installed. It's breaking the null coalescing operator (??) which was introduced in PHP 7.0.
    – Dwight
    Dec 13, 2017 at 3:45
  • possibly same question, u can see here. stackoverflow.com/questions/45992685/…
    – M.Islam
    Dec 13, 2017 at 4:38

6 Answers 6

10

Error 500 could appear from having server's PHP version lower than minimum version requirement by Laravel.

From my experience, the problem came out when I'm using Laravel 5.6 when my PHP version was still at 7.0 while it actually requires at least PHP 7.1.3. Changing my PHP version at PHP Selector in cPanel solved the issue.

Make sure your server's PHP version is equal or higher than what your Laravel version needs.

7

First time, you can check your php info

<?php
phpinfo();
?>

and you can search "mbstring" in there...

mbstring

if mbstring still not installed, you can ask the provider to installed that.

if already installed and still got the error 500, better you must check your php version in phpinfo(). And clear your cache with php artisan command. when you have a permission to shell, you can try to check your php version with command "php -v" and see the default php with which php.

1
  • ahh, yes, my phpinfo did't have that, I will install it first. thank you! Dec 14, 2017 at 3:18
1

Just to bring to light on some issues I faced with my upload on a shared hosting and how I saved it. The error 500 appeared my page.

After several investigation, I discovered that the hidden files both in the public folder and the main app were not included in my uploads.

So just make sure you show hidden files before archiving/uploading

As it will not get uploaded/archived if not enabled to show hidden files.

The absence of these files too generate the 500 error.

I worked with laravel 5.5.*

0

None of the above solutions worked for me.. so tried :

php composer.phar install

on my shared hosting after uploading (for the first time) my project build on my local machine and it worked.

0

Make sure you had run composer install and should have a .env file

0

Also make sure the folder and files have correct permission. The following is how to set the correct permissions.

find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;

https://stackoverflow.com/a/11512211/8621306

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.