The following tutorial column of composer will introduce to you how to install Composer on Linux. I hope it will be helpful to friends in need!
Linux Installation Composer Getting Started
Practice environment:
Virtual machine: Oracle VM VirtualBox.
System: CentOS 7.
安装方式一: 参考网址:https://learnku.com/composer/t/4484/composer-mirror-use-help#741738来安装。 1、下载:wget https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer 2、修改权限:chmod a+x /usr/local/bin/composer 3、查看版本:composer -V 安装方式二: 参考网址:https://pkg.phpcomposer.com/来安装。 1、下载安装脚本:php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" 2、执行安装过程:php composer-setup.php 3、删除安装脚本:php -r "unlink('composer-setup.php');" 4、将 Composer 安装到系统环境变量 PATH 所包含的路径下面: sudo mv composer.phar /usr/local/bin/composer 5、更新Composer:composer selfupdate 安装方式三: 参考网址:https://getcomposer.org/download/来安装。 php -r -r --r
选项一、全局配置(推荐) composer config -g repo.packagist composer https://packagist.laravel-china.org 选项二、单独使用 如果仅限当前工程使用镜像,去掉 -g 即可,如下: composer config repo.packagist composer https://packagist.laravel-china.org
composer config -g --unset repos.packagist
(1)
Error: No matching certificate subject alias (Subject Alternative Name).
The requested host name is “dl.laravel-china.org”.
To connect to dl.laravel-china.org in an unsafe way, use "--no-check-certificate".
Solution: According to the prompt in the error, add --no-check-certificate
wget --no-check-certificate https://dl.laravel-china.org/composer .phar -Oc /usr/local/bin/composer
(2)
Failed to decode zlib stream
Solution: The PHP script does not have write permission, add it to the script Write permission, chmod a x composer-setup.php.
(3)
Composer: Line 1: Unexpected symbol `newline' with syntax error near it
Solution: There may be a problem with the downloaded file, you can try to download it again, or Find other download sources to download.
(4)
failed to open stream: HTTP request failed!
Solution: When using php to download files, this error is reported, modify php.ini, and set allow_url_fopen If it is on, remove the comment before user_agent="PHP",
If there are still errors, try setting user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)".
(5) If an error is still reported and there is no idea to solve it, then download it directly using windows, transfer it to the virtual machine using ftp or shared file, and then use it directly.
Download link: https://getcomposer.org/download/1.8.6/composer.phar, you can choose other versions.
The above is the detailed content of How to install Composer on Linux. For more information, please follow other related articles on the PHP Chinese website!