skip to Main Content

I have already uploaded my laravel project folder into cpanel hosting. I have followed many examples here but still getting the famous 500 internal error. This is what I have done:

I has separated public folder in my laravel project and put in my public_html folder. I have made the rest of my laravel project into myapp folder.

Into my public_html folder, I have changed this lines:

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

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

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

This is my .env file:

APP_NAME=Driveostle
APP_ENV=local
APP_KEY=base64:xxx
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://www.driveostle.ma

This is my .htaccess file:

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    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>

This is my server.php file:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <[email protected]>
 */

$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
}

require_once __DIR__.'/public/index.php';

I still got the HTTP ERROR 500 after typing my domaine name.

After searching here, I have found someone that asked for editing the .htaccess by adding this code:

<IfModule mod_rewrite.c>
   RewriteEngine On 
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

The error that I obtained was different:

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.

Also, my PHP Selector version in Cpanel, I have choose the 7.1 version.

And in my composer.json file:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "intervention/image": "^2.4",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "mews/purifier": "^2.0"
    },
...

I don’t know what is missed in my configuration, It is my first time hosting a laravel website, I hope the elements that I have posted will give you an idea of what I have missed.

If you need any file content, I will post it with pleasure.

Thank you

3

Answers


  1. With so many times I’ve deployed my Laravel apps on a Shared hosting (cPanels), I’ve created a document so I could help my fellow developers, try this one out

    Deploying your Laravel Application to a Shared Hosting (cPanel)

    Login or Signup to reply.
  2. I might be late to this but for future reference you can check the php version and try changing it

    Login or Signup to reply.
  3. I had the same thing happen and I had to add the following code to the AppServiceProvider boot section:

     public function boot()
        {
            $this->app->bind('path.public', function() {
            return base_path().'/../public_html';
            });
        }
    

    I hope this helps anyone having the same issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search