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
3
Answers
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 calledchatbot
inpublic_html
, I wrote inindex.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 inzigzagfamily.com
So I must go back another two folders to be in the root directory to be able to accesschatbot
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';
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 removepublic_html
folder and create next symbolic link.run command in terminal hosting root
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:
and save your main current project in
current
folder.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:
To:
Finally, Be shure that the bootstrap folder and storage folder have 0775 permission (for testing).