woff 發表於 2021-9-13 21:41:48

如何在 Cpanel 上安裝 PHP Composer

在本指南中,我們將介紹在 Cpanel 上安裝 PHP Composer。Composer 是一個 PHP 依賴管理工具。它允許您聲明項目所依賴的庫,並為您管理(安裝/更新)它們。

Composer 沒有預裝 PHP 或 Cpanel,您必須手動安裝它。按照以下步驟在 Cpanel 上安裝 PHP Composer。


第 1 步:在 EasyApache 中安裝所需的 PHP 模塊
要使用 Composer,您必須在 EasyApache 中啟用多個 PHP 模塊。

1. 登錄到您的 Cpanel WHM 儀表板並蒐索 EasyApache


2. 單擊 EasyApache 4 以啟用 PHP 模塊
3.單擊按鈕Customize。


4. 導航到PHP Extensions 部分


5. 搜索Iconv & Mbstring要安裝的擴展。

6. 單擊安裝開關以啟用這些擴展的安裝

7.在查看頁面上,單擊按鈕Provision以安裝擴展。


8. 如果安裝成功,您應該會收到消息Provision process finished. ClickDone。

第 2 步:設置所需的 PHP 指令
您必須更新php.ini文件中的以下 PHP 指令:
allow_url_fopen = On
detect_unicode = Off

1. 導航 WHM > MultiPHP INI Editor > Editor Mode


安裝 composer cpanel 打開 php multi ini 編輯器
2. 在下拉菜單上編輯 PHP 版本的 INI 設置。在php.ini 文件末尾添加以下幾行。

allow_url_fopen = on
detect_unicode = off
它應該如下所示

安裝 composer cpanel 編輯 php ini
您必須單擊“保存”以應用新更改。


第 3 步:在 Cpanel 服務器上安裝 PHP Composer
現在我們已經正確設置了依賴項,通過 ssh 進入您的 Cpanel 服務器並下載 Composer 安裝程序:

wget https://getcomposer.org/installer -O composer-installer.php
運行安裝程序腳本以全局部署 Composer:

php ./composer-installer.php --install-dir=/usr/local/bin --filename=composer
您應該會看到如下輸出:

使用 Composer 的所有設置都正確
正在下載...

Composer(版本 1.7.3)成功安裝到:/usr/local/bin/composer
使用它: php /usr/local/bin/composer
您應該能夠使用composer命令

______
/ ____/___ ____ ___ ____ ____ ________ _____
// / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                  /_/
Composer 版本 1.7.3 2018-11-01 10:05:06

用法:
命令 [選項] [參數]

選項:
______/ ____/_______ ________________________ / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___// /___/ /_/ / / / / / / /_/ / /_/ (__)__/ /\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/                  /_/Composer version 1.7.3 2018-11-01 10:05:06Usage:command ______
/ ____/_______ ________________________
/ /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__)__/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                  /_/
Composer version 1.7.3 2018-11-01 10:05:06

Usage:
command

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-DIRIf 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 版本,請鍵入以下命令:

# composer -V
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user ? yes
Composer version 2.1.6 2021-08-19 17:11:08

幹得好!。您現在已經在您的 Cpanel 服務器上安裝了 PHP 的 Composer 依賴管理器。


參考文章
頁: [1]
查看完整版本: 如何在 Cpanel 上安裝 PHP Composer