在本教程中,我們將向您展示如何在 Debian的 10. 對於那些不知道的人,Composer 是一個了不起的依賴管理工具,用於安裝和更新動態 PHP 項目和應用程序的庫。 該軟件用於促進項目依賴項的安裝和更新,這些依賴項還顯示項目要求所需的適當版本。
本文假設您至少對 Linux 有基本的了解,知道如何使用 shell,最重要的是,將您的網站託管在自己的 VPS 上。 安裝非常簡單,假設您在 root 帳戶下運行,如果不是,您可能需要添加 'sudo
' 到命令以獲得 root 權限。 我將向您展示在 Debian 10 (Buster) 服務器上逐步安裝 Composer。
先前的要求
- 運行以下操作系統之一的服務器:Debian 10 (Buster)。
- 建議您使用全新的操作系統安裝以避免潛在問題。
- 對服務器的 SSH 訪問(或者如果您在桌面上,則只需打開終端)。
- UN
non-root sudo user
或訪問root user
. 我們建議充當non-root sudo user
但是,如果您在以 root 身份操作時不小心,它可能會損害您的系統。
在 Debian 10 上安裝 Composer
第 1 步。在安裝任何軟件之前,重要的是通過運行以下命令確保您的系統是最新的 apt
終端中的命令:
sudo apt update sudo apt upgrade
接下來,您需要為 Composer 安裝一些依賴項:
sudo apt install curl php-cli php-mbstring git unzip
步驟 2. 在 Debian 上安裝 Composer。
首先,按照以下命令下載 Composer Setup:
cd ~ curl -sS https://getcomposer.org/installer -o composer-setup.php
您必須通過運行以下命令驗證安裝程序是否與在 Composer 公鑰或簽名頁面上找到的最新安裝程序的數據完整性相匹配的 SHA-384 哈希:
HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
然後檢查安裝腳本是否損壞:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
生產:
Installer Verified
現在運行以下命令在裡面全局安裝 Composer /usr/local/bin
目錄:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
然後運行以下命令確認安裝:
composer
生產:
______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ / __ `__ / __ / __ / ___/ _ / ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / ____/____/_/ /_/ /_/ .___/____/____/___/_/ /_/ Composer 1.6.3 2019-10-20 16:46:27 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
恭喜! 您已成功安裝 Composer。 感謝您使用本教程在 Debian 10 Buster 系統上安裝 Composer。 如需更多幫助或有用信息,我們建議您參考 作曲家的官方網站.