如何在我的域(domain.com)中托管Laravel 5.8应用程序? [英] How to host Laravel 5.8 Application in my domain (domain.com)?

查看:56
本文介绍了如何在我的域(domain.com)中托管Laravel 5.8应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将基于 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 from public folder to public_html\xyz folder.
    • Modify index.php like this

      require __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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆