403禁止共享主机上的Laravel [英] 403 Forbidden Laravel on shared hosting
问题描述
我有一个共享主机,我正在尝试使其laravel项目在其上运行,我正在使用voyager进入管理面板。
I have a shared hosting and I'm trying to make my laravel project works on it, I'm using voyager to the admin panel.
我把我的/ public_html内的应用程序公用文件夹,而项目的其余部分与/ public_html处于同一级别,因此如下所示:
I put my app public folder inside the /public_html and the rest of the project on the same level of the /public_html, so it looks like this:
.bash_history
.bash_logout
.bash_profile
.bashrc
.cache
.cpanel
.htpasswds
logs
mail
app -> my project
public_ftp
public_html -> where my app public folder is
.ssh
tmp
etc
...
我几乎可以完成所有工作,但是管理面板无法正常工作。
I have managed to work almost everything, but the admin panel is not working properly.
当我访问www.example.com/admin时转到www.example.com/admin/login,我放了我的凭据并提交了表单,返回到同一页面后,然后我在Chrome上检查了网络标签,并显示了以下消息:
When I access www.example.com/admin it goes to www.example.com/admin/login, I put my credentials and submit the form, after it returns to the same page, then I checked the network tab on Chrome and it appears the following message:
Request URL: http://example.com/admin/login
Request Method: GET
Status Code: 403 Forbidden
有人知道如何解决吗?
谢谢。
推荐答案
通常,您应该将公用文件夹的文件复制到public_html文件夹,并将其他文件夹放在public_html之外,因为
Usually, you should copy your files of public folder to the public_html folder and put other folders outside of public_html because it is available to the whole world.
您应该修改public / index.php文件,其中将包含以下详细信息:
You should modify the public/index.php file will following details:
//line 24
require __DIR__.'/../app/vendor/autoload.php';
// line 38
$app = require_once __DIR__.'/../app/bootstrap/app.php';
由于在public_html文件夹中有公用文件夹,因此应再添加一个(..)
Since you have public folder inside public_html folder, you should add one more (..)
//line 24
require __DIR__.'/../../app/vendor/autoload.php';
// line 38
$app = require_once __DIR__.'/../../app/bootstrap/app.php';
域或子域
指向您的域或{{您的域}} / public的子域
Domain or subdomain
Point your domain or subdomain to {{your_domain}}/public
eg: In your case, if you visit www.abc.com it should point to /public_html/public.
for other cases, it should point to /public_html
注意:
别忘了更新.env文件
Note:
Don't forget to update your .env file
- 设置APP_ENV = production
- APP_DEBUG = false
- LOG_CHANNEL =每日//被视为良好做法
- 您的数据库凭据
- 以及其他必要的更改...
- set APP_ENV=production
- APP_DEBUG=false
- LOG_CHANNEL=daily // considered good practice
- Your database credentials
- And other necessary changes...
权限
通常,您不需要更改文件和文件夹权限。如果需要将文件夹设置为755,并将文件设置为644
Permissions
Normally you don't need to change files and folder permission. If you need to then set Folders to 755 and files to 644
请不要将权限设置为777
这篇关于403禁止共享主机上的Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!