Question

I am trying to install Composer on my KnownHost VPS. When I run this command:

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

I get this error message:

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 phar extension is missing.
Install it or recompile php without --disable-phar

How do I install the phar extension? I am running PHP 5.4.22 on my VPS.

Was it helpful?

Solution 2

In the end I solved this by getting my host to rebuild PHP with PDO support.

OTHER TIPS

You can modify your php.ini file to get this working. (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. @jerrygarciuh On dreamhost, follow the directions here)

After you have added your php.ini/phprc file, add these lines to the file (just the first line if your server doesn't use Suhosin for security):

extension = phar.so 
suhosin.executor.include.whitelist = phar

restart php if you need to (insert php version number with no decimals if different):

killall -9 php70.cgi

then check to make sure it is working:

php -m | grep Phar

Finish with the install of composer and you should be good to go.

Mind to install phar extension for php.

urpmi php-phar

or

apt-get install php-phar

I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:

  1. First install your required PHP version: sudo apt install php7.2

  2. Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

  3. Check whether the composer is working by simply typing composer

If the composer is working properly, you are good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top