如何在laravel 8中将公共文件夹更改为public_html? [英] How to change public folder to public_html in laravel 8?

查看:22
本文介绍了如何在laravel 8中将公共文件夹更改为public_html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的应用程序部署在Cpanel上的共享主机上,其中主文档根目录public_html但Laravel项目public

推荐答案

您必须按照两个步骤将应用程序的公用文件夹更改为Public_html,然后才能部署它或您可以执行的任何操作:)

  1. 编辑AppProvidersAppServiceProviderRegister()方法&;添加此代码。

     // set the public path to this directory
     $this->app->bind('path.public', function() {
         return base_path().'/public_html';
     });
    
  2. 打开server.php您可以看到此代码

    if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
       return false;
    }
    
    require_once __DIR__.'/public/index.php';
    

只需替换为:

  if ($uri !== '/' && file_exists(__DIR__.'/public_html'.$uri)) {
   return false;
  }

  require_once __DIR__.'/public_html/index.php';

然后使用php artisan serve为您的应用程序提供服务,您也可以将其部署到您的Cpanel共享主机上,其中主文档根为public_html

这篇关于如何在laravel 8中将公共文件夹更改为public_html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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