Linux 安装 composer

来源:互联网 发布:谁在淘宝上买过精密管 编辑:程序博客网 时间:2024/06/06 07:29

一条龙命令

```curl -sS https://getcomposer.org/installer | php  ```可能会出现以下问题:

- curl not found。需要安装curl。
- php not found。请参考php not found
- 提示文件夹 is not writable、open_basedir restriction in effect。请参考这篇文章

使composer.phar变为可执行。

chmod 777 composer.phar

安装好后,可以将composer.phar 软链接到/usr/bin中。就可以在任意地方使用。

ln -s /www/composer/composer.phar /usr/bin/composer

检查安装是否成功

composer -v

切换国内源,因为某些原因使用国内镜像会快一些。

composer config -g repositories.packagist composer http://packagist.phpcomposer.com

可能会出现这些问题:

  • 报错 Your configuration does not allow connection to http://packagist.phpcomposer.com. See https://getcomposer.org/doc/06-config.md#secure-http for details.
    原因没有禁用https
    方法

    composer config secure-http false
  • 报错 The Process class relies on proc_open, which is not available on your PHP installation.
    原因 禁用了proc_open函数。因为直接操作系统函数有一定风险,所以在php.ini中会禁用。
    方法
    在php.ini中,找到disable_functions选项,看看后面是否有proc_open函数被禁用了,如果有的话,去掉即可。Proc_get_status也是一样。

  • 同上,Proc_get_status和escapeshellarg被禁用。同样的方法解决。

原创粉丝点击