php 安装 Composer 时遇到问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14437588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
having trouble installing composer
提问by Om3ga
I am installing composer with the following cammand
我正在使用以下命令安装作曲家
curl -s https://getcomposer.org/installer | php
But I am keep getting below error message
但我不断收到以下错误消息
Zafars-MacBook-Pro:etc zafarsaleem$ curl -s https://getcomposer.org/installer | php
#!/usr/bin/env 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
A php.ini file does not exist. You will have to create one.
How can I install composer be removing above error?
如何安装 Composer 以消除上述错误?
EDIT
编辑
Zafars-MacBook-Pro:etc zafarsaleem$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Latest Edit
最新编辑
After some research I found that php.inifile which is being used is in /etc/php.ini. However, when I checked this file in /etcfolder it wasn't there. /etcfolder contained php.ini.defaultfolder which linked to /private/etc/php.ini.default. So I added detect_unicode = Offin /etc/php.ini.defaultand the renamed this file to php.ini. Now when I execute below command
经过一番研究,我发现php.ini正在使用的文件在/etc/php.ini. 但是,当我在/etc文件夹中检查此文件时,它不存在。/etc文件夹包含php.ini.default链接到/private/etc/php.ini.default. 所以我说detect_unicode = Off在/etc/php.ini.default和重命名该文件php.ini。现在当我执行以下命令时
curl -s https://getcomposer.org/installer | php
OR
或者
sudo curl -s https://getcomposer.org/installer | php
Then I get following errors
然后我收到以下错误
Zafars-MacBook-Pro:/ zafarsaleem$ sudo curl -s https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Download failed: failed to open stream: Permission denied
Downloading...
Download failed: failed to open stream: Permission denied
Downloading...
Download failed: failed to open stream: Permission denied
The download failed repeatedly, aborting.
How can I install composer on my computer and remove above problems? Please help
如何在我的计算机上安装 composer 并解决上述问题?请帮忙
回答by Mike Graf
To download / install on MacOSX, you can do the following stepsortry the homebrewsteps below:
要在 MacOSX 上下载/安装,您可以执行以下步骤或尝试以下自制步骤:
Goto a directory you can write to:
cd ~
get composer:
curl -sS https://getcomposer.org/installer| php
move composer into a bin directory in your $PATH var:
sudo mv composer.phar /usr/local/bin/composer
double check composer works
composer about
(optional) Update composer:
sudo composer self-update
转到您可以写入的目录:
光盘~
获取作曲家:
curl -sS https://getcomposer.org/installer| php
将 composer 移动到 $PATH var 中的 bin 目录中:
须藤 mv composer.phar /usr/local/bin/composer
仔细检查作曲家的作品
作曲家关于
(可选)更新作曲家:
须藤作曲家自我更新
brew update
brew tap homebrew/homebrew-php
brew tap homebrew/dupes
brew tap homebrew/versions
brew install php55-intl
brew install homebrew/php/composer
回答by Andreyco
Try this instead and change the setting on the fly, just for this command
试试这个并动态更改设置,仅针对此命令
curl -sS https://getcomposer.org/installer | php -d detect_unicode=Off
回答by nem.daz
In Ubuntu Vivid 15.04. Try: Steps:
在 Ubuntu Vivid 15.04 中。尝试: 步骤:
- Open terminal and write: sudo suand press Enter.
- Paste this: curl -sS https://getcomposer.org/installer| phpand press Enter. (This install composer, Wait to finish)
- And Finaly Write exit
- 打开终端并输入: sudo su并按 Enter。
- 粘贴这个:curl -sS https://getcomposer.org/installer| php并按 Enter。(这个安装composer,等待完成)
- 最后写退出
Note: Sorry, my English is bad :(
注意:对不起,我的英语不好:(
回答by bobbmob
I had the same error. I ended up adding sudo to the php side and it worked for me.
我有同样的错误。我最终将 sudo 添加到 php 端,它对我有用。
curl -sS https://getcomposer.org/installer | sudo php
回答by blnarayanan
In case if you dont have curl in your system, you can still install composer using the following command
如果您的系统中没有 curl,您仍然可以使用以下命令安装 composer
Go to a directory where you can write,
转到您可以写入的目录,
cd yourDirectory
php -r "readfile('https://getcomposer.org/installer');" | php -d detect_unicode=off
回答by Inluxc
sudo curl -sS https://getcomposer.org/installer| sudo php -- --install-dir=/usr/local/bin
sudo curl -sS https://getcomposer.org/installer| 须藤 php -- --install-dir=/usr/local/bin
Run this command and it will work, so i think :D
运行此命令,它会起作用,所以我认为:D

