[转] (Ubuntu) Install PHP Composer

Step 1:

(The recommended path, not needed.)

$ cd /usr/local/bin

Step 2:

(install)

$ sudo curl -s https://getcomposer.org/installer | sudo php
 

Step 3:

(Add execute permissions.)

$ sudo chmod a+x composer.phar

$ alias composer='/usr/local/bin/composer.phar'
 

Step 4:

(This step is not necessary. If needed, you can use this script to update Composer.)

$ sudo composer.phar self-update
 

Step 5: 检测 composer 是否安装成功,运行如下命令:

$ composer -V

原文网址:http://my.oschina.net/lujian863/blog/161746

Home Getting Started Download Documentation Browse Packages

Download Composer

Run this in your terminal to get the latest Composer version:

$ curl -sS https://getcomposer.org/installer | php
 

Or if you don't have curl:

$ php -r "readfile('https://getcomposer.org/installer');" | php
 

This installer script will simply check some php.ini settings, warn you if they are set incorrectly, and then download the latest composer.phar in the current directory

Installer Options

--install-dir

You can install composer to a specific directory by using the --install-dir option and providing a target directory. Options must be appended to -- so that PHP ignores them, like -- --install-dir=bin, example:

$ curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
 

--filename

You can specify the filename (default: composer.phar) using the --filename option. example:

$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
 

--version

You can install composer to a specific release by using the --version option and providing a target release. example:

$ curl -sS https://getcomposer.org/installer | php --version=1.0.0-alpha8
 

Manual Download

If you prefer to download the phar manually, here are the available versions:

https://getcomposer.org/download/

升级 composer

gao@gao-VirtualBox:/var/log/nginx$ /usr/local/bin/composer.phar -V
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/usr/local/bin/composer.phar self-update" to get the latest version.
Composer version b63634396bb181845b4ec3cfe5df0cd2819453ad 2013-12-16 14:34:19
gao@gao-VirtualBox:/var/log/nginx$ /usr/local/bin/composer.phar self-update


                                                                                                                        
  [Composer\Downloader\FilesystemException]                                                                             
  Filesystem exception:                                                                                                 
  Composer update failed: the "/home/gao/.composer/cache" directory used to download the temp file could not be written

sudo /usr/local/bin/composer.phar self-update

更新 已有的laravel 项目

gao@gao-VirtualBox:/var/www$ /usr/local/bin/composer.phar create-project laravel/laravel laravelAuth --prefer-dist


                                                                                                                                  
  [ErrorException]                                                                                                                
  file_put_contents(/home/gao/.composer/cache/repo/https---packagist.org/packages.json): failed to open stream: Permission denied 
                                                                                                                                  


create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [package] [directory] [version]

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info

  [ErrorException]          
  zlib_decode(): data error 

解决方法:

composer爆错:zlib_decode():data error

先运行

composer diagnose

若全部返回OK

 

再执行

composer install -vvv

一般就行

gao@gao-VirtualBox:~$ sudo composer diagnose
[sudo] password for gao:
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: OK
gao@gao-VirtualBox:~$

 

有时候有提示秘药错误的,去Git上生成一个即可

参考网址:http://www.07net01.com/2015/08/894255.html

本文出自 “枷罗博客” 博客,请务必保留此出处http://jhomephper.blog.51cto.com/8558055/1681854

gao@gao-VirtualBox:~$ sudo apt-get install php5-mcrypt
[sudo] password for gao:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系:
 php5-mcrypt : 依赖: phpapi-20121212
               依赖: php5-common (= 5.5.29+dfsg-1+deb.sury.org~vivid+3) 但是 5.6.4+dfsg-4ubuntu6.2 正要被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

Step 1:

(The recommended path, not needed.)

$ cd /usr/local/bin

Step 2:

(install)

$ sudo curl -s https://getcomposer.org/installer | sudo php
 

Step 3:

(Add execute permissions.)

$ sudo chmod a+x composer.phar

$ alias composer='/usr/local/bin/composer.phar'
 

Step 4:

(This step is not necessary. If needed, you can use this script to update Composer.)

$ sudo composer.phar self-update
 

Step 5: 检测 composer 是否安装成功,运行如下命令:

$ composer -V

原文网址:http://my.oschina.net/lujian863/blog/161746

Home Getting Started Download Documentation Browse Packages

Download Composer

Run this in your terminal to get the latest Composer version:

$ curl -sS https://getcomposer.org/installer | php
 

Or if you don't have curl:

$ php -r "readfile('https://getcomposer.org/installer');" | php
 

This installer script will simply check some php.ini settings, warn you if they are set incorrectly, and then download the latest composer.phar in the current directory

Installer Options

--install-dir

You can install composer to a specific directory by using the --install-dir option and providing a target directory. Options must be appended to -- so that PHP ignores them, like -- --install-dir=bin, example:

$ curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
 

--filename

You can specify the filename (default: composer.phar) using the --filename option. example:

$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
 

--version

You can install composer to a specific release by using the --version option and providing a target release. example:

$ curl -sS https://getcomposer.org/installer | php --version=1.0.0-alpha8
 

Manual Download

If you prefer to download the phar manually, here are the available versions:

https://getcomposer.org/download/

升级 composer

gao@gao-VirtualBox:/var/log/nginx$ /usr/local/bin/composer.phar -V
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/usr/local/bin/composer.phar self-update" to get the latest version.
Composer version b63634396bb181845b4ec3cfe5df0cd2819453ad 2013-12-16 14:34:19
gao@gao-VirtualBox:/var/log/nginx$ /usr/local/bin/composer.phar self-update


                                                                                                                        
  [Composer\Downloader\FilesystemException]                                                                             
  Filesystem exception:                                                                                                 
  Composer update failed: the "/home/gao/.composer/cache" directory used to download the temp file could not be written

sudo /usr/local/bin/composer.phar self-update

更新 已有的laravel 项目

gao@gao-VirtualBox:/var/www$ /usr/local/bin/composer.phar create-project laravel/laravel laravelAuth --prefer-dist


                                                                                                                                  
  [ErrorException]                                                                                                                
  file_put_contents(/home/gao/.composer/cache/repo/https---packagist.org/packages.json): failed to open stream: Permission denied 
                                                                                                                                  


create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [package] [directory] [version]

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info

  [ErrorException]          
  zlib_decode(): data error 

解决方法:

composer爆错:zlib_decode():data error

先运行

composer diagnose

若全部返回OK

 

再执行

composer install -vvv

一般就行

gao@gao-VirtualBox:~$ sudo composer diagnose
[sudo] password for gao:
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: OK
gao@gao-VirtualBox:~$

 

有时候有提示秘药错误的,去Git上生成一个即可

参考网址:http://www.07net01.com/2015/08/894255.html

本文出自 “枷罗博客” 博客,请务必保留此出处http://jhomephper.blog.51cto.com/8558055/1681854

gao@gao-VirtualBox:~$ sudo apt-get install php5-mcrypt
[sudo] password for gao:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系:
 php5-mcrypt : 依赖: phpapi-20121212
               依赖: php5-common (= 5.5.29+dfsg-1+deb.sury.org~vivid+3) 但是 5.6.4+dfsg-4ubuntu6.2 正要被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

猜你喜欢

转载自gxl-ct001.iteye.com/blog/1989299
今日推荐