如何在我的域(domain.com)中托管Laravel 5.8应用程序? [英] How to host Laravel 5.8 Application in my domain (domain.com)?
问题描述
我试图将基于 Laravel 5.8 的应用程序托管在我的域(domain.com/xyz)上,类似于在先前版本中编写的基于Laravel的项目(将所有内容保留在根路径上,并保持
I have tried to host my Laravel 5.8 based application on my domain (domain.com/xyz) as similar to the Laravel based project written on the previous version (keep everything on root path and keep the public folder in public_html, but it does not work.
例如,我的文件夹在根目录中为xyz. index.php 文件仍在 ../public_html/xyz 中而不是在 home/my_website/xyz
For example, my folder is xyz in the root directory. index.php file still searching that directory in the ../public_html/xyz rather than home/my_website/xyz
这是我的代码:
require __DIR__.'/../xyz/vendor/autoload.php';
$app = require_once __DIR__.'/../xyz/bootstrap/app.php';
推荐答案
- 在
public_html
的根目录中创建一个文件夹XYZ. - 将您的应用程序内容移至xyz文件夹.
- 将
index.php
和.htacces
文件从public
文件夹移至public_html\xyz
文件夹. -
像这样修改
index.php
- Create a folder, XYZ in your root of
public_html
. - Move the contents of your app to to xyz folder.
- Mover
index.php
and.htacces
file frompublic
folder topublic_html\xyz
folder. Modify
index.php
like thisrequire __DIR__.'vendor/autoload.php';
$app = require_once __DIR__.'bootstrap/app.php';
例如,如果您的css和js停止工作,请在导入之前添加
{{asset('public')}}/
And if your css and js stops working add
{{asset('public')}}/
before your imports, for example<link href="{{ asset('public') }}/demo/demo.css" rel="stylesheet" /> <script src="{{ asset('public') }}/js/core/jquery.min.js"></script>
然后您可以访问 http://example.com/xyz
这篇关于如何在我的域(domain.com)中托管Laravel 5.8应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Create a folder, XYZ in your root of