Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install / enable the PHP phar extension?

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.

like image 265
Garry Pettet Avatar asked Feb 26 '14 16:02

Garry Pettet


2 Answers

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.

like image 134
jatemack Avatar answered Sep 21 '22 11:09

jatemack


Mind to install phar extension for php.

urpmi php-phar

or

apt-get install php-phar
like image 32
7Tonin Avatar answered Sep 24 '22 11:09

7Tonin