简体   繁体   English

在centos上安装作曲家

[英]installing composer on centos

I'm trying to install composer on my server (centos) but I keep getting this error : The phar extension is missing. 我正在尝试在服务器(centos)上安装composer,但始终出现此错误:phar扩展名丢失。 Install it or recompile php without --disable-phar ps:I am trying to install composer to work with laravel 安装它或不使用--disable-phar ps重新编译php:我正在尝试安装composer以与laravel一起使用

Specifically for CentOS 专为CentOS

Edit the file /etc/php.d/20-phar.ini and remove the ; 编辑文件/etc/php.d/20-phar.ini并删除; character in front of the line: 该行前面的字符:

extension=phar.so

Now the phar extension is enabled. 现在phar扩展已启用。

Composer is provided as a phar as that extension is a standard part of PHP 5.3 which is also the minimum required version for running Composer at all. Composer是作为Phar提供的,因为该扩展是PHP 5.3的标准部分,它也是运行Composer的最低要求版本。

If you have a weird version of PHP 5.3+ without the phar extension you could also convert it to a zipball or tarball via online tools , unpack it to /usr/local/share/composer , and then symlink manually from /usr/local/bin/composer to /usr/local/share/composer/bin/composer . 如果您具有怪异的PHP 5.3+版本,但没有pha​​r扩展名,则也可以通过在线工具将其转换为zipball或tarball,将其解压缩到/usr/local/share/composer ,然后从/usr/local/bin/composer手动进行符号链接/usr/local/bin/composer/usr/local/share/composer/bin/composer Assuming no other settings are preventing installation that should work as well. 假设没有其他设置阻止安装也可以正常进行。

PHAR is part of the PHP core since some years now. 从现在开始,PHAR已成为PHP核心的一部分。 Its already installed as dynamic/shared extension, but probably and simply not activated in your case 它已经安装为动态/共享扩展,但在您的情况下可能并且根本没有激活

Please check your php extension folder for a file "phar.so". 请检查您的php扩展文件夹中的文件“ phar.so”。

To enable the extension: 启用扩展:

  1. Go to your php.ini and enable extension = phar.so 转到您的php.ini并启用extension = phar.so
  2. Check the loaded PHP Extensions with php -m and look for "Phar" 使用php -m检查已加载的PHP扩展,并查找“ Phar”
  3. Then re-run the Composer install 然后重新运行Composer安装

First, you need to get composer.phar by doing : 首先,您需要通过以下操作获取composer.phar:

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

And move the composer.phar for using globally : 并移动composer.phar以在全局范围内使用:

mv composer.phar /usr/local/bin/composer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM