skip to Main Content

I am uploading a simple subscription page for my website using cPanel. I uploaded the files to public_html, moved the files from public folder and modify index.php so it points to the application. The PHP version I used to code this application is 7.3 but I had to select the 7.2 version in the host because that was the latest available.

When I load my website I get this error “This page isn’t working bazzaar.net is currently unable to handle this request.
HTTP ERROR 500”

When I remove everything from the index.php file and add a simple echo the page loads.

I really need HELP with this. the error logs are below:

Stack trace:

#0 /home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php(198): SymfonyComponentHttpFoundationResponse->setStatusCode(500)
#1 /home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php(214): SymfonyComponentHttpFoundationResponse->__construct('<!doctype html>...', 500, Array)
#2 /home3/bazzaar/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(328): SymfonyComponentHttpFoundationResponse::create('<!doctype html>...', 500, Array)
#3 /home3/bazzaar/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(305): IlluminateFoundationExceptionsHandler->convertExceptionToResponse(Object(SymfonyComponentEr in /home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php on line 450

my .htacess file

suPHP_ConfigPath /opt/php72/lib

Options -MultiViews -Indexes

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]

# Use PHP72 as default

12

Answers


  1. Chosen as BEST ANSWER

    The problem seems to be with PHP version. Laravel 6 requires PHP >=7.2.5 and Hostgator only had 7.1 as the latest version. So i had to contact customer support and ask for the latest PHP version.

    Also, mbStrings which was a requirement for laravel was turned off.


  2. Assuming the cpanel has no other website and your laravel project is supposed to be the default project.

    1. Zip your entire Laravel project and export your DB to sql
    2. Login to cPanel and navigate to File Manager
    3. Ensure you’re in the root folder, then click “Upload”
    4. Select your zip file and wait for upload to complete
    5. Unzip the uploaded file
    6. Move the content of public to public_html folder
    7. Go back to Cpanel and navigate to Databases
    8. Created a database and add (create if non exist) a DB user
    9. Click on your fresh DB, and click “Import”
    10. Select your exported SQL file
    11. Try to access your laravel website using the domain url

    This website might provide more details https://dev.to/asapabedi/deploying-laravel-5-applications-on-shared-hosting-without-the-use-of-ssh–16a6

    Login or Signup to reply.
  3. AS OF MAY 2020 LARAVEL 7.0

    This is what worked for me:

    1. Update the php version of cpanel to the requirements of laravel version say laravel 7.0 needs https://laravel.com/docs/7.x/installation

    2. Check that all required extensions are installed

    3. Then if you are having problems with .htacess, I recommend that you test by..
      creating a simple index.html
      just add a line like

      Hello World

      then zip all files in your public_html (including the .htaccess) and upload the index.html
      refresh the target url say domain.com
      when it works you are ready for the next step
      (if it doesn’t try debugging / finding out why)

    4. Upload your database (assuming its already exported) by…
      Go to MySQL Databases
      create a database with the exact name of your database to be added
      then create a MySQL user and give him all priviledges to the database
      Go to phpmyadmin in cpanel and import the exported sql file

    5. Zip your working laravel project and upload it to the home folder

    6. In cpanel extract and…
      PLEASE NOTE:
      place all folders in the home
      pick contents of public including .htaccess to public_html

    THE FOLDER AND FILE STRUCTURE SHOULD BE THE SAME AS YOUR LARAVEL PROJECT ON
    YOUR COMPUTER (except public is now public_html)

    WARNING: DON’T TOUCH YOUR index.php or server.php

    1. Make hidden files visible in your cpanel then finally edit the .env file by…
      Only editing DB username and password (I expect the DB name to be the same)
      Also you want to leave APP_DEBUG as true for testing (YOU MUST TEST)

      When all is well change it to false

    2. If you have no database, what are waiting for refresh already
      Though even with a Database NOWS THE TIME refresh

    Login or Signup to reply.
  4. follow these steps:

    1. check .htaccess file on root or subdomain.
    2. if move files of public to root => change index.php contents /../ to /

    e.g

    require DIR.’/../vendor/autoload.php’;

    TO

    require DIR.’/vendor/autoload.php’;

    AND

    $app = require_once DIR.’/../bootstrap/app.php’;

    TO

    $app = require_once DIR.’/bootstrap/app.php’;

    1. check the php version (on laravel 6+ i used php7.4 and problem solved)
    2. check .env file
    Login or Signup to reply.
    1. Create a new directory named public_html/myapp on your host.

    2. Inside your Laravel project you have a public directory. Copy the content of that public directory into the public_html/myapp directory you created on your host.

    3. On the same level with public_html folder (not inside it!), create a new directory named myapp-laravel on your host.

    4. Excepting the public folder, copy every folder and file (ex. app folder, .env file, …) from your Laravel project into the myapp-laravel folder on your host.

    5. Edit the public_html/myapp/index.php file like this:

    • Change require
      __ DIR__.'/../vendor/autoload.php';

      to require

      __ DIR__.'/../../myapp-laravel/vendor/autoload.php';
    • Change
      require_once __ DIR__.'/../bootstrap/app.php';

      to

      require_once __ DIR__.'/../../myapp-laravel/bootstrap/app.php';

    Find article here.

    Login or Signup to reply.
    1. zip and upload your project.
    2. unzip
    3. configure the root folder of your domain to be "public", the public folder inside laravel unzipped folder.
    Login or Signup to reply.
  5. Firstly, upload the project in a folder in your cpanel. in my case it is named project.
    Then, upload the public folder in public_html, and change the index.php file based on the folder you uploaded your project.

    Login or Signup to reply.
    1. Create a subdomain on hosting and map it to a folder e.g: "abc"
    2. In folder "abc" upload laravel project zip (with vendor folder) then extract it
    3. Map subdomain to the public folder of laravel i.e. "abc/public".
    4. Create a database & user and assign that user to the database with all privileges
    5. Import the DB dump in the database created above.
    6. Add DB user/password in laravel .env file.

    Note: If you face any due to cache remove file config.php in directory bootstrap/cache.

    Login or Signup to reply.
  6. You don’t need to make changes to the structure of Laravel. Just copy below htaccess code and paste in .htaccess file at the root of your laravel project.

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^$ public/index.php [L]
        RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
    </IfModule>
    
    
    Login or Signup to reply.
  7. If you are using an Apache server you can do the following simple step

    Step 1: just upload your all source code on the server (make sure database & .env
    set well)
    i) make zip and extract it
    ii) deploy code using git or take a clone from a repository and install all
    dependencies

    Step 2: Make a .htaccess file on the project root directory and copy below code and paste it into this file.

    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^$1 [N]
    RewriteCond %{REQUEST_URI} (.w+$) [NC]
    RewriteRule ^(.*)$ public/$1 
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ server.php
    

    I get this answer from this video so please say thanks to him
    https://www.youtube.com/watch?v=6Qbd9HTh7AE (Thank you)

    Login or Signup to reply.
  8. Most of cpanel have now included a tab for laravel project. just click on the laravel tap and the install, follow simple steps given and setup your folder
    screen shot of the tap
    then create index.php file with redirecting power to your public folder having laravel project. ether the following code..

      <?php
        header("refresh: 1; https://wesley.io.ke/lara/public/");
        ?>
    

    all is done access your project now using the domsin you entered when creating the project

    Login or Signup to reply.
  9. I got an effective less painless system for both Laravel 8 and 9 version. You can follow, I hope this will help you:

    1. In the public folder, you will get total 4 files. .htaccess, favicon.ico, index.php and robots.txt.
    2. Just move all these files to the root of your application, that means, outside the public folder.
    3. Open the index.php file with editor and change 2 lines.
      Change this line:
    require __DIR__.'/../vendor/autoload.php';

    To:

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

    AND Change this line:

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

    To:

    $app = require_once __DIR__.'/bootstrap/app.php';
    1. If you had images in public folder that you used in your application, you will see that throughout the application, your images are not showing.
    2. So now go to .env file and add this line:
       ASSET_URL=public
    3. All tasks are done!

    Now just upload your application to the shared server and it will work normally.

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