phpinfo() function shows that my PHP version (5.1.6) is installed --without-pear in the configure command section.
How do I install pear?
The Getting and installing the PEAR package manager page should help you : it gives informations on how to install the PEAR package manager, on both windows, Linux, and Mac.
Basically, if your Linux distribution comes with a PEAP package, you should install it.
For instance, on Ubuntu1, there is a php-pear package ; so, you'd use :
apt-get install php-pear
Else, if it doesn't, with a version of PHP >= 5.3, you should be able to use this :
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
With PHP 5.1, though, this is not going to work, as phar support has been added in PHP 5.3...
As a sidenote : PHP 5.1 is really outdated !
PHP 5.3 is more than one year and a half old ; even PHP 5.2 is not maintained anymore... maybe you should consider upgrading ?
1It seems you are running some kind of Redhat-based distribution, but I don't have one of those, so I cannot say if there is a PEAR package for it -- there is probably one, though.
--without-pear only means that the PEAR bits were not immediately created when PHP was compiled.
This usually happens when an operating system vendor that provides packages and wants to split off bits and pieces into their own individually installable parts.
Given the age of the PHP you're talking about, you're probably on RHEL or a derivative like CentOS. Check the package manager for a php-pear package.
Related
Please help with php 7 extensions on CentOS 7.
When trying to isntall extension, for example memcache and memcached using the command yum --enablerepo=remi-php74 install php-memcache php-memcached I got the message that this packages are already installed.
php --modules also shows they are present. But I can't find them in /etc/opt/remi/php74/php.d and /opt/remi/php74/root/lib64/php/modules.
I attached screenshot of phpinfo() as well phpinfo, there are no additional extensions...
Please advice what I'm doing wrong, I'm not very strong in this DevOPS things :-)
Also added php --ini response php --ini
For a proper installation please follow the Wizard instructions
If you need a single version, php-* packages are simpler to install and use
If you need multiple versions, php74-php-* are available
You can read the repository FAQ: Difference between php-* and php##-php-* packages ?
So as you are running php74-php you need
yum install php74-php-pecl-memcache php74-php-pecl-memcached
But if you need a single version, probably better to remove all php74* packages and only use php-* ones.
I always get this weird questions about how stuff works behind the scenes. I know how to compile php from source, and I know that if you compile it from source and forget to add a module/library you need to re-compile php to add it. However, if you install php lets say using yum, and then you want to add another extension, you just need to install that extension. For example, today I was working on a recently installed Fedora 18 machine, and php was missing the DOM library, which is weird, since that library is enabled by default. It seems like yum installs php with that extension disabled. Anyway, since it was missing, I had to do this:
sudo yum install php-xml
And that solved the problem, but it made me wonder, how is the installation process in this case? Is php re compiled? and if so, how does it remember all the other extensions that may have been added before? Or is the xml extension installed separately and somehow linked into php?
I haven't found any info about this, and I'm really curious as to how it works.
When you install php extension packages using a package manager like yum or apt-get, the repositories have the already compiled so extensions for the version of php that came with the system. For example, if you're on Ubuntu 12.04, and you do a apt-get install php-mysqlnd, it fetches the deb package from the repository which contains the pre-compiled mysqlnd.so and a default mysqlnd.ini. This works because the deb package has the compiled version according to the default dependencies that are installed for the 12.04 release. If some dependencies are missing, the precompiled deb packages are fetched for the same, thus eliminating the need for configuration and make. This make it a lot faster and easier. Almost plug and play!
You can build extensions separately, you don't have to rebuild your php every time you need to add a new extension, you just need to define the extensions that needs to be loaded under [extensions] in your php.ini.
When your building php you can specify which extensions you need to be statically (included) in the php binary vs which once you want as a shared library.
configure --enable-http=static --with-openssl=shared
// http extension will be included in PHP
// openssl extension will be compiled as separate DLL
Yum connects to repositories of pre-compiled rpm's. Yum will download the rpm and its dependencies and install them.
Yum will use different repositories for different OS's. For example Fedora 18 has a different repostitory of pre-compiled rpms then Fedora 17 would have.
Yum is just a glorified dependency management system
I have two installations of php on my server. One version of php is 5.2.0 configured with pear, and the other is 5.2.9 configured --without-pear. My server is running Red Hat Enterprise Linux AS release 4 (Nahant Update 9).
I would like to uninstall pear (and also PHPUnit) from php 5.2.0, and then reinstall it as part of the 5.2.9 version of php. The pear installation docs don't really cover this type of a situation, although they do tell Linux users to "consult the documentation for the respective distribution" in the event that they want to install pear with a version of php that was configured --without-pear. I am having trouble finding such documentation, and even if I did, I am not sure how to remove the existing pear installation first.
Here is a partial answer to my own question: After trial and error, I discovered that you can uninstall pear by running this command:
$ sudo pear uninstall pear
I would like to see this added to the official pear docs, since they don't mention uninstalling pear at all.
Use the Command Help
pear help
You'll see the uninstall command listed in the output. :)
Output
Commands:
build Build an Extension From C Source
bundle Unpacks a Pecl Package
channel-add Add a Channel
...
uninstall Un-install Package
...
I'm trying to install a couple of pear packages but have an issue with the version of PHP I'm running. Firstly I get:
sudo pear install phix/Autoloader
Failed to download phix/Autoloader, latest release is version 3.0.0, but it requires PHP version "5.3.0", use "channel://pear.phix-project.org/Autoloader-3.0.0" to install
Cannot initialize 'channel://pear.phix-project.org/Autoloader', invalid or missing package file
Package "channel://pear.phix-project.org/Autoloader" is not valid
install failed
I then try and install as follows:
sudo pear install channel://pear.phix-project.org/Autoloader-3.0.0
phix/Autoloader requires PHP (version >= 5.3.0), installed version is 5.2.6-1+lenny13
No valid packages found
install failed
Would I be correct in assuming the error is related to the version of PHP I'm running? If so, is there a way of getting the pear install to ignore the PHP version requirements?
Thanks
Even if you bring PEAR to ignore the version, you cannot use the packages, because the requirements are not fulfilled. There are really good reasons, why the package maintainers set the requirements.
Thus: No, you can't.
Please take a look into
pear help install
This should list you all available options. As written in my comment above, I don't think it makes sense, but you can just try harder to make pear installing the package anyway. The package then might just not work in the end, but well, that are "just" requirements you'd like to ignore anyway, so go ahead ;)
I'm using yum on CentOS 5.1 - I hand-compiled PHP 5.2.8 from source, but have other packages installed using yum. I need to install a PHP extension via pecl, and it requires phpize to be installed as well. However, doing the following yields a dependency error:
sudo yum install php-devel
Error: Missing Dependency: php = 5.1.6-20.el5_2.1 is needed by package php-devel
Since I actually have a newer version of PHP already installed, how can I force yum to ignore this? Do I need to hand-compile pecl/phpize from source? I admittedly never had a problem before, it only seems to be because of a combo of compiles and yum installs.
Any thoughts?
Thanks,
Kyle
In general:
If you build it yourself, it goes into /usr/local, and is only accessible to other things in /usr/local.
If you install from RPM/Yum, it goes into /usr, and is accessible to /usr and /usr/local.
So, if you want to install PHP tools using home-compiled PHP, install them into /usr/local as well: typically, with GNU-type software, that'd be something like:
./configure --prefix=/usr/local && make && sudo make install
or
make prefix=/usr/local all && sudo make prefix=/usr/local install
…although most software should default to /usr/local unless you override its prefix setting.
If you want to “hand-build” packages that are based upon RPM's, you can use
yumdownloader --source WHATEVER-PACKAGE
rpm -i WHATEVER-PACKAGE.rpm
rpmbuild -bp ~/rpm/SPECS/WHATEVER-PACKAGE.spec
(your path equivalent to ~/rpm may vary; rpmbuild --showrc will tell you where)
This downloads the .src.rpm package, which contains the upstream (original author's) source (usually a tarball) as well as OS-specific patches; installs the sources into ~/rpm (or your rpmbuild prefix); and then unpacks the sources and applies the patches into ~/rpm/BUILD/WHATEVER-PACKAGE/
From there, you can do the configure/make steps yourself, with the /usr/local prefix
Of course, just installing from RPM's is far easier :-)
yum doesn't know anything about your hand-compiled php version. You can either bypass RPM's dependency resolution by installing the package using rpm --nodeps and hope it works.
Or install the php version you compiled yourself in another directory so it can coexist with the old version from yum, so everyone is happy (not sure if that's possible, I guess it depends on whether your apps use a hardcoded path to php or not).
Or, if you are lucky, a third-party repository like EPEL or RPMForge might have a newer php package, so you don't have to compile your own.
As a rule of thumb, it's better to have one package management in the system, so you'll be better off packaging everything in RPMS and managing it via yum. It will save you lots of time in the long run.
If you absolutely want to have something (fe PHP) compiler from sources by hand, use stow/checkinstall/... or any other solution which would enable you to do rudimentary package management for source-compiled stuff.
Regerding your question, you could try to override dependency checking by downloading RPM of the required package an doing "rpm -i --force file.rpm", since yum does not have any option for forced installations