亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將 Laravel 核心文件移動到 private_html 目錄

將 Laravel 核心文件移動到 private_html 目錄

PHP
侃侃無極 2023-10-01 16:59:37
作為安全預防措施,我的老板要求我將 Laravel 7 應用程序移出 public_html 文件夾并移至 private_html 中。所以我的目錄結構如下所示:public_html/public/private_html/ <-- All the rest of the Laravel core files, app, config, routes, .env, etc.現在,正如預期的那樣,自從我移動了文件后,當我訪問該網站時,我收到了 HTTP ERROR 500。我如何告訴 Laravel 我的公共文件夾在哪里,以便可以返回服務我的網頁?我需要編輯哪些配置文件?謝謝你的幫助。編輯 1:在嘗試了 Youssef 的建議之后,一切都很好,除了我跑步的時候php artisan storage:link我得到:編輯2:我能夠通過打開 config/filesystems.php 并更改來修復“php artisan storage:link”:'links' => [     public_path('storage') => storage_path('app/public'), ],到:'links' => [     '/new/directory/public_html/public/storage' => storage_path('app/public'), ],然后,當我輸入:php artisan storage:link創建了一個新的符號鏈接。
查看完整描述

1 回答

?
莫回無

TA貢獻1865條經驗 獲得超7個贊

在 public/index.php 中將這兩個文件的路徑更改為它們的當前路徑。


autoload.php的第一行路徑


__DIR__.'/../vendor/autoload.php';


require __DIR__.'/../../private_html/vendor/autoload.php';

app.php的第二行路徑


$app = require_once __DIR__.'/../bootstrap/app.php';


$app = require_once __DIR__.'/../../private_html/bootstrap/app.php';

并將其放入\App\Providers\AppServiceProvider register()設置公共目錄路徑的方法中。


**

 * Register any application services.

 *

 * @return void

 */

public function register()

{

    // ...


    $this->app->bind('path.public', function() {

        return base_path().'/../public_html/public';

    });

}

最后,如果您需要直接訪問存儲的文件,請使用命令重新分配存儲目錄的路徑:


php artisan storage:link

您還可以將所有文件從 移動public_html/public到public_html并調整我上面提到的路徑


查看完整回答
反對 回復 2023-10-01
  • 1 回答
  • 0 關注
  • 97 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號