Reputation: 8290
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.
Upvotes: 12
Views: 66882
Reputation: 79
Follow the below steps for easy installation of app.phar
:
app.phar
file.app.phar
file in the desired directory.php app.phar
This will install the app.phar
in the directory where the file is placed.Global installation:
app.phar
in the environment variable.app.phar
in any directory which is already added in environment variable. Ex: /usr/local/bin/Now app.phar
can be accessed globally. Run php app.phar
in cmd to execute the app.
Note: To execute the app without typing php
& .phar
, we need to create a app.bat
file.
The content of app.bat
should be:
@ECHO OFF
php %~dp0app.phar %*
place app.bat
in the same location as app.phar
.
Now execute app.phar
by just typing app
in the cmd.
Upvotes: 0
Reputation: 405
I got the same issue in Ubuntu 16.04. After wasting two hours, I came up with this solution:
First install your required PHP version: sudo apt install php7.2
Install the composer. curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Check whether the composer is working by simply typing
composer
If the composer is working properly, you are good to go.
Upvotes: 0
Reputation: 89
Mind to install phar extension for php.
urpmi php-phar
or
apt-get install php-phar
Upvotes: 3
Reputation: 91
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.
Upvotes: 9
Reputation: 8290
In the end I solved this by getting my host to rebuild PHP with PDO support.
Upvotes: 1