[PHP] CentOS6.7にComposerをインストールする
CentOS 6.7でComposerを使いたかったので、その時のメモ。
curlでインストールするには下記のコマンドを実行する。
curl -sS https://getcomposer.org/installer | php
が、php.iniの設定で怒られた。
$ curl -sS https://getcomposer.org/installer | php Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again: The detect_unicode setting must be disabled. Add the following to the end of your `php.ini`: detect_unicode = Off The php.ini used by your command-line PHP is: /usr/local/php/lib/php.ini If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.
エラーメッセージにある通り、php.iniに追記する。
$ php --ini Configuration File (php.ini) Path: /usr/local/php/lib Loaded Configuration File: /usr/local/php/lib/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none) $ vi /usr/local/php/lib/php.ini # detect_unicode = Off を追加
再度実行すると、僕の環境だと下記のようなエラーが出た。
$ curl -sS https://getcomposer.org/installer | php Some settings on your machine may cause stability issues with Composer. If you encounter issues, try to change the following: PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub. Recompile it without this flag if possible Downloading 1.0.0... Composer successfully installed to: /home/vagrant/composer.phar Use it: php composer.phar
「Install自体はできたけど、GitHubの認証周りであがっているissueにひっかかるからできればphpから設定削除してrecompileしてくれよ」という話らしい。
僕の環境だとphpをソースからコンパイルしていたので、指定通りのオプションを削除して再度コンパイルする。
$ cd <phpのソースがあるパス> $ vi configure.nice # --with-curlwrappers の行を削除 $ ./configure.nice $ make $ make install
再度実行した結果、エラーは発生しなくなった。
$ curl -sS https://getcomposer.org/installer | php All settings correct for using Composer Downloading 1.0.0... Composer successfully installed to: /home/vagrant/composer.phar Use it: php composer.phar
パスを通してコマンドが実行できるようになれば、無事Composerが使用できるようになる。
$ sudo mv composer.phar /usr/local/bin/composer $ composer --version Composer version 1.0.0 2016-04-05 13:27:25














