TShopping

 找回密碼
 註冊
搜索
查看: 1668|回復: 0
打印 上一主題 下一主題

[教學] 如何在 Cpanel 上安裝 PHP Composer

[複製鏈接]
跳轉到指定樓層
1#
發表於 2021-9-13 21:41:48 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
 
Push to Facebook
在本指南中,我們將介紹在 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. Click  Done

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


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


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

  1. allow_url_fopen = on
  2. detect_unicode = off
複製代碼

它應該如下所示

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


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

  1. wget https://getcomposer.org/installer -O composer-installer.php
複製代碼

運行安裝程序腳本以全局部署 Composer:

  1. 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 [options] [arguments] ______
  / ____/___  ____ ___  ____  ____  ________  _____
/ /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.7.3 2018-11-01 10:05:06

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

  1. [root@ns1 woff]# composer -V
  2. Do not run Composer as root/super user! See https://getcomposer.org/root for details
  3. Continue as root/super user [yes]? yes
  4. Composer version 2.1.6 2021-08-19 17:11:08
複製代碼

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


參考文章

 

臉書網友討論
*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-4-27 03:28 , Processed in 0.085694 second(s), 25 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表