Linux 系統 Composer 安裝


Composer 是個包管理工具

在項目中使用它會很方便

本文中用 PHP 安裝

 

1、下載安裝

執行命令 curl -sS https://getcomposer.org/installer | php

 

2、配置環境變量

mv composer.phar /usr/local/bin/composer

 

3、設置國內鏡像

composer config -g repo.packagist composer https://packagist.phpcomposer.com

 

4、遇到的問題

Q1:/usr/bin/env: php: No such file or directory
A1:找不到 php 執行文件,cp /usr/local/php/bin/php /usr/local/bin/php

Q2:執行 composer 拋出 Killed
A2:緩存不足導致,linux 增加緩存
free -m
mkdir -p /var/_swap_
cd /var/_swap_
dd if=/dev/zero of=swapfile bs=1M count=2000
mkswap swapfile
swapon swapfile
echo “/var/_swap_/swapfile none swap sw 0 0” >> /etc/fstab
free -m


Q3:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- league/flysystem 1.0.53 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
- league/flysystem 1.0.53 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
- league/flysystem 1.0.53 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
- Installation request for league/flysystem (locked at 1.0.53) -> satisfiable by league/flysystem[1.0.53].

To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/php/lib/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json to its original content.

A3:安裝 fileinfo 擴展包
cd /usr/local/src/php-7.3.4/ext/fileinfo/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM