Binod Bhandary
Binod Bhandary

Reputation: 472

laravel Server error 500 in cpanel hosting

I'm hosting laravel 5.1 in my cpanel but it always accured error.I tried every method (htaccess, chmod 644 and storage give o r+W) but it doesn't work in my cpanel but when i removed following line from index.php of public folder it give access to index.php file:

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

so it give access to mine folder . Can anybody help me? can it cause due to php version of cpanel?

Upvotes: 7

Views: 42561

Answers (6)

Lalarukh khan
Lalarukh khan

Reputation: 170

By following one of the above answer I wrote this code in start of index.php file of public folder (public/index.php):

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

After reloading site, I saw the issues were coming from vendor folder. Means composer folder is not updated yet. I ran these commands in Terminal of CPANEL:

cd laravelfolder //public_html or your code root directory
composer update

Upvotes: 0

Sajid Javed
Sajid Javed

Reputation: 507

Paste this code at the top of your index.php file which will be in the public folder:

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

Then visit the URL of your project and there you will see the issue because which laravel is throwing this error.

Upvotes: 11

hashem abedi
hashem abedi

Reputation: 1

check these steps:

  1. check .htaccess file on root or subdomain
  2. if move files of public to root => change index.php contents /../ to /
  3. check the php version (on loravel 5+ i used php7.2 and problem solved)
  4. check .env file

Upvotes: 0

Binod Bhandary
Binod Bhandary

Reputation: 472

Thank to all.. i solved it .. in cpanel there is php selector. so i changed it 5.6 and uploads all the folder of vender than give right permission to ech folder and files..

Upvotes: 1

Saiyan Prince
Saiyan Prince

Reputation: 4020

Procedure on how to host your Laravel 5.1.* application on any shared hosting:

  1. Open Filezilla or any of your favorite FTP Client.
  2. Login and get into the home directory of your hosting account.
  3. Create directory called laravel-app or anything that you want inside your shared hosting account home directory.
  4. Copy everything except public directory from your application's root directory inside the newly created folder. In this case laravel-app.
  5. Now copy the contents of public directory in your public_html directory.
  6. Once everything is uploaded, open up index.php file which resides in public_html directory in any of your favorite text editor.

Change the following line:

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

to

require __DIR__.'/../../laravel-app/bootstrap/autoload.php';

And also change the following line:

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

to

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

Before Uploading:

Please make sure that you have enabled all the plugins that are required by Laravel application. And also you are using PHP >= 5.5.* . If you don't know how to view which plugins are enabled by default.

Follow these steps:

  1. Login to your cPanel account from the browser.
  2. Scroll down way to the bottom where they say select PHP Version. Click on it.
  3. From the dropdown, select PHP 5.5.6 or any of your choice, but it has to be PHP >= 5.5.*
  4. There is a list of PHP Extensions below the dropdown that can be installed. You can leave it as it is or select the extension(s) that you wish to install. For example, if your application has file uploading feature, then you need to install the fileinfo extension by check marking that extension and clicking the button Save.

DONE. Your Laravel application is live on a shared hosting account.

You can check it by going to yourdomain.com

Hope this helps you. Happy Coding. Cheers.

Upvotes: 1

Qazi
Qazi

Reputation: 5135

For Laravel, these are required, confirm this

PHP >= 5.5.9
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension

Upvotes: 2

Related Questions