skip to Main Content

I have a confusing error with laravel 7 project. This project when I uploaded it into the main directory It worked successfully. but when I uploaded it into a subdomain it gives me 500 error.
I did steps that mentioned in this answer but it didn’t work also
How to set up a laravel project on cPanel subdomain?
Hope someone help me
enter image description here
enter image description here
enter image description here

3

Answers


  1. Chosen as BEST ANSWER

    First Of All, I'd like to thank all contributors. I knew the reason for the error. In this image:
    [![enter image description here][1]][1]

    The file called public_html is not in the root directory as it might seem it is. It's just a shortcut from : /domains/zigzagfamily.com/public_html So when I created a folder called chatbot in public_html, I wrote in index.php:

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

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

    And it's wrong because as I said public_html is here:

    /domains/zigzagfamily.com/public_html So when I go back two folders, I'm now in zigzagfamily.com So I must go back another two folders to be in the root directory to be able to access chatbot folder that is located in the root directory. Summery: the right code was:

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

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


  2. Laravel project start form public folder.

    Bad practice to start it from root.

    You must place your project into root of hosting (at the same level as the public_html folder), then remove public_html folder and create next symbolic link.

    run command in terminal hosting root

        ln -s your_project_folder/public public_html
    

    In this case your no need edit index.php files.

    If you planing to use any deployer in the future I recommend to use next folders structure:

        /public_html <- link to 
        /sites/your_project_name/current/public
    

    and save your main current project in current folder.

    Login or Signup to reply.
  3. Since laravel uses pretty URLs, using zigzagfamily.com/chatbot will not work.

    In your cPanel create a subdomain (chatbot.zigzagfamily.com) pointing to /public_html/chatbot

    Into the /public_html/chatbot folder, upload/move your /chatbot/public content.

    Modify your /public_html/chatbot/index.php file from:

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

    To:

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

    Finally, Be shure that the bootstrap folder and storage folder have 0775 permission (for testing).

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