简体   繁体   English

如何安装/启用 PHP phar 扩展?

[英]How do I install / enable the PHP phar extension?

I am trying to install Composer on my KnownHost VPS.我正在尝试在我的 KnownHost VPS 上安装Composer 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?如何安装 phar 扩展? I am running PHP 5.4.22 on my VPS.我在我的 VPS 上运行 PHP 5.4.22。

You can modify your php.ini file to get this working.您可以修改 php.ini 文件以使其正常工作。 (Some hosts use a phprc file to enable different settings in PHP instead of php.ini. @jerrygarciuh On dreamhost, follow the directions here ) (有些主机使用 phprc 文件来启用 PHP 中的不同设置,而不是 php.ini。@jerrygarciuh 在 Dreamhost 上,请按照此处的说明操作

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):添加 php.ini/phprc 文件后,将这些行添加到文件中(如果您的服务器不使用 Suhosin 以确保安全,则只添加第一行):

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

restart php if you need to (insert php version number with no decimals if different):如果需要,请重新启动 php(如果不同,请插入不带小数的 php 版本号):

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.完成composer的安装,你应该很高兴。

Mind to install phar extension for php.注意为 php 安装 phar 扩展。

urpmi php-phar

or或者

apt-get install php-phar

最后,我通过让我的主机使用 PDO 支持重建 PHP 来解决这个问题。

I got the same issue in Ubuntu 16.04.我在 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首先安装你需要的PHP版本: 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只需输入composer即可检查 Composer 是否正常工作

If the composer is working properly, you are good to go.如果作曲家工作正常,你就可以开始了。

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

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