簡體   English   中英

如何從Ubuntu的Laravel應用程序訪問Windows服務器中的文件?

[英]How to access files within a Windows server from a Laravel application in Ubuntu?

我需要通過ssh從Ubuntu上托管的Laravel應用程序連接到Windows服務器,在其中我要檢索一些文件以便在應用程序中使用它們。

Laravel應用程序是在Ubuntu上使用nginx 1.14托管的,並使用PHP 7.3.6和Laravel 5.8。

我需要在Laravel中使用的文件(通過“使用”,我指的是讀取,編輯,下載和上傳)需要保留在該Windows服務器中,因為對於創建這些文件的人來說,將它們轉移到Linux上會很麻煩( Excel工作表,文本文件,csv文件)和對我來說,因為我必須在這里配置每台PC上的samba共享文件夾。

我嘗試使用ssh連接到Windows服務器,但它顯示登錄提示,但沒有憑據在起作用(它在域內,並且我嘗試使用“ domain \\ username”,但::無效)。

摘要

  • Windows服務器中的文件:xlsx,csv,txt
  • 操作:讀取,編輯,下載,上傳。
  • Laravel應用程序托管在Ubuntu中。
  • 無法通過ssh從Ubuntu連接到Windows服務器。

  • Ubuntu服務器配置:

    • Ubuntu 18.04
    • Nginx 1.14.0
    • Laravel 5.8
    • PHP 7.3.6

我的登錄嘗試:

sys@server:~$ sudo ssh arebollar@xx.xx.xx.xx
arebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

arebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

arebollar@xx.xx.xx.xx's password:
Received disconnect from xx.xx.xx.xx port 22:2: Too many attempts.
Disconnected from xx.xx.xx.xx port 22


sys@server:~$ sudo ssh AzureAD\arebollar@xx.xx.xx.xx
AzureADarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

AzureADarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

AzureADarebollar@xx.xx.xx.xx's password:
Received disconnect from xx.xx.xx.xx port 22:2: Too many attempts.
Disconnected from xx.xx.xx.xx port 22


sys@server:~$ sudo ssh domain\arebollar@xx.xx.xx.xx
domainarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

domainarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

domainarebollar@xx.xx.xx.xx's password:
Received disconnect from xx.xx.xx.xx port 22:2: Too many attempts.
Disconnected from xx.xx.xx.xx port 22

我將這個答案發布給任何遇到像我這樣的問題的人。

我終於使用ftp解決了這個問題,訪問了像這樣的文件:

Storage::disk('ftp')->files($this->filePath.$filename)

我在config / filesystems.php中添加了ftp本地磁盤:

'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

...

        'ftp' => [
            'driver'   => 'ftp',
            'host'     => env('FTP_HOST'),
            'username' => env('FTP_USERNAME'),
            'password' => env('FTP_PASSWORD'),
        ],

最后將ftp參數添加到.env文件並運行:

php artisan config:cache

希望這對其他人有幫助。 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM