skip to Main Content

I just finished setting up database into the cpanel and uploaded the project into the cpanel. I zipped the project and uploaded that way. I moved all the files from ‘public’ folder into the public_html and the rest into a new directory called ‘house’ and after that I edited the index.php file as follows

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

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

Still the website is inaccessible. I must be missing something from the beginning. In firefox, the page is blank and google chrome says This page isn’t working. Do I have to change the .env and database.php inside config? I have followed all the instruction shown in some of the helpful videos but nothing seem to work for me.

My current .env file has following lines (no credential set up)

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

3

Answers


  1. May be this will help you,

    1. Clear all your cache before uploading the project in live.
    2. Change your index.php file like you did.
    3. Change your server.php file

      if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
      return false;
      }
      
      require_once __DIR__.'/public/index.php';
      

    to,

       if ($uri !== '/' && file_exists(__DIR__.'/../public_html'.$uri)) {
          return false;
       }
    
       require_once __DIR__.'/../public_html/index.php';
    
    Login or Signup to reply.
  2. Copy everything into public_html from public folder and change path to

    require __DIR__.'/house/vendor/autoload.php
    
    Login or Signup to reply.
  3. Note: I advise you to leave everything as it is including the .htaccess file

    • Compress the entire project folder on your local machine. You’ll get a zip file – laravel50.zip

    • Open your shared hosting cPanel.

    • Click on ‘File Manager’

    • Click on ‘Upload’

    • Upload the laravelproject.zip to the root directory – not the public_html

    • Extract the laravelproject.zip to file manager

    • Open the laravel50 folder and MOVE the CONTENTS of the public folder to your cpanel’s public_html folder. You can as well delete the empty public folder now.

    • Navigate to the public_html folder and locate the index.php file. Right click on it and select Code Edit from the menu.

      • This will open up another tab showing the cpanel code editor.

      • change the following lines (22 and 36) from

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

    to

    require __DIR__.'/../laravel50/bootstrap/autoload.php';
    ...
    $app = require_once __DIR__.'/../laravel50/bootstrap/app.php';

    • Please do not change the contents of your .htaccess file (Unless you know what you are doing 🙂)
      the .htaccess file should look something like this.

    Options -MultiViews

                  RewriteEngine On
    
                # Redirect Trailing Slashes…
                  RewriteRule ^(.*)/$ /$1 [L,R=301]
    
                # Handle Front Controller…
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteRule ^ index.php [L]
                  </IfModule>`
    
    • If everything went well, going to http://yourdomain.com should throw database errors (if you have models running on your app). Not to worry! The next phase is migrating your databases to your shared hosting.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search