php56 - CentOS - Remi Repo - php

I just installed php 5.6 on a test box, and the normal cli php interpreter doesn't appear to exist:
$ -> php -v
-bash: php: command not found
$ -> php56 -v
PHP 5.6.13 (cli) (built: Sep 3 2015 13:41:04)
If I try to do a yum install php --enablerepo=remi then it tries to install php 5.4.
So it's obvious that php56 is a cli interpreter, but I've always been used to just typing php vs php56. Is this the new norm, or is there another step for installing php56 on CentOS (6.7)? Is it as simple as creating a symlink? ln -s /usr/bin/php56 /usr/bin/php
Steps to upgrade:
$ -> yum remove php* --enablerepo=remi
$ -> yum install php56* --enablerepo=remi
Thx to Remi for the push in the right direction, here's what my repo config looks like:
[upstream_remi54]
name=Remi - CentOS - $releasever/$arch
baseurl=http://mirrors.mediatemple.net/remi/enterprise/$releasever/remi/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[upstream_remi56]
name=Remi - CentOS - $releasever/$arch
baseurl=http://mirrors.mediatemple.net/remi/enterprise/$releasever/php56/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://rpms.famillecollet.com/RPM-GPG-KEY-remi
This works well if you want to completely replace existing PHP, vs running versions in parallel. I have to keep PHP 5.4 in place for Roundcube and Postfix Admin, as some of the modules necessary for those to work have not yet been ported, so that server has to stay 5.4 for now.

php-* are base packages, 1 repository per version
"remi" => php 5.4
"remi-php55" => php 5.5
"remi-php56" => php 5.6
"remi-php70" => php 7.0 (Release Candidate, not ready for prod)
php56-* packages are Software Collections, parallel installation allowing to run multiple versions of PHP.
See : http://blog.remirepo.net/pages/English-FAQ
So, if you only want a single php version 5.6
yum --enablerepo=remi-php56 install php-cli (and other needed modules)
And you can also enable the repository for future update (as the "remi-php56" is safe and only provides php 5.6 and its extension)
yum-config-manager --enable remi-php56

Related

Ubuntu 18.04 using PHP version that is not installed as a module

Using the commmand php -v on a Ubuntu 18.04 server is displaying PHP version 8.1.14, but no PHP8.* module is installed.
I have tried running the command: sudo update-alternatives --config php which displays:
Available PHP versions
Disabling the PHP8.1 module will show me that the module is not installed:
module not installed
While php -v is really showing me PHP8.1:
PHP version
I have tried to purge the PHP 8 version with the following command:
sudo apt-get purge php8.*
It showed me 0 modules were marked for removal, just to be sure I also ran autoremove & autoclean commands.
When I display the PHP info, it also shows the 8.1 version:
PHP info
I need to get the server back to version 7.4 to make some installations function properly, I have tried all options above but did not succeed. How can I downgrade to PHP Version 7.4?
While I was installing the PHP Selector add-on for DirectAdmin, I noticed Zend modules were being installed for 7.4. Perhaps these were missing for the server to switch back to version 7.4. Problem solved!

Linux add PHP 7.4 to Webmin/Virtualmin

My current setup of Webmin/Virtualmin has PHP 5.6 and 7.2. More and more composer packages have a requirement of PHP 7.4. I don't want to have 7.4 as the default PHP, I have sites on the server that need 5.6 (I know, not great but it's the way it is), so I'm trying to get 7.4 installed in the same structure as 7.2, in the /opt/rh folder.
The version of Linux is "CentOS Linux release 7.8.2003 (Core)"
I've tried to do this about 5 times and failed each time, there is just no information (that I can find) out there to say how to do this. Any help would be massively appreciated.
If you need to keep default version of PHP, make sure to install PHP 7.4 from [remi-safe] repos.
Install Remi Release repo and clear cache:
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm && yum clean all
Install PHP 7.4 packages:
yum -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd}
It's clearly described in our documentation page on how to install different versions of PHP for Virtualmin.
You can have couple version of php running in the same time.
Check this
Multiple PHP Version on Centos

XDEBUG installation reading wrong PHP version

I have an Ubuntu 16.04 vagrant box running on php 7.1. When I try to build xdebug by running ./configure in xdebug-2.6.0 I get
Check for supported PHP versions... configure: error: not supported. Need a PHP version >= 7.0.0 and < 7.3.0 (found 5.5.9-1ubuntu4.24)
PHP -v yields
Xdebug requires Zend Engine API version 320170718.
The Zend Engine API version 320160303 which is installed, is outdated.
PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:27:08) ( NTS )
So the system is running 7.1, but for some reason the configure script thinks we're still on 5.5.9
I've hit google pretty hard, but still can't find a way to update the Zend engine either.
Any ideas?
It happens because you're configuring with default settings and that is different from the PHP version you're trying to configure.
Just like you saw the PHP version using the php -v command, check the php-config version using the php-config --version command, it should be the same as php -v, but in your case, it would be different and hence this issue.
Now let's talk about how we can solve it. Since you need a different version of config, you should point that to the configure command.
For example, in your case, you need php-config7.1 (because you're using PHP v7.1, similarly for 7.2 you have php-config7.2 and so on)
To point the configure command to a specific PHP version you need to specify that as a flag called with-php-config and the value should be the location of the php-config file, a sample would be
./configure --with-php-config=/usr/bin/php-config7.1
Hope this solves the problem.
I assume you run phpize before running ./configure. Instead you need to run phpize7.1 and then ./configure
if you don't have phpize7.1 installed you can install it via:
sudo apt install apt install php7.1-dev

How can I update my PHP 5.3.3 to PHP 5.3.8 Linux Centos

I want to update my php 5.3.3 to php 5.3.8, I already downloaded PHP5.3.8.tar.gzip.
My PHP 5.3.3 located in /usr/bin/php. When I try to install PHP5.3.8.tar.gzip and do this command:
./configure
make
make install
It installed in different location /usr/local/bin/php.
So now I have 2 php 5.3.3 and php 5.3.8. So I try to install it again and run this
./configure -prefix=/usr/bin/php
make
make install
This time an error occurred:
Installing PHP SAPI module: cgi
mkdir: cannot create directory `/usr/bin/php': File exists
mkdir: cannot create directory `/usr/bin/php/bin': Not a directory
make: [install-sapi] Error 1 (ignored)
Installing PHP CGI binary: /usr/bin/php/bin/
cp: accessing `/usr/bin/php/bin/#INST#29239#': Not a directory
make: *** [install-sapi] Error 1
Please help me, I want to delete the php5.3.8 I installed in /usr/local/bin/php
and update the /usr/bin/php to php5.3.8. I need php5.3.8 version only.
Thanks.
Generally on CentOS, you want to leave this sort of thing to yum.
yum update php
or
sudo yum update php
You can also replace the installation with a newer version. 5.3.X is not supported any longer, so you could do:
yum install yum-plugin-replace
yum replace php --replace-with php55
If you don't have php 5.5 in yum, first do this:
cd ~
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-11.ius.centos6.noarch.rpm
rpm -Uvh epel-release-6-5.noarch.rpm ius-release-1.0-11.ius.centos6.noarch.rpm
If you don't have wget installed:
yum install wget
PLEASE NOTE FOR ALL OTHERS FINDING THIS THROUGH GOOGLE!!!
The URL's that I linked in the wget commands are the current releases of the epel and ius repos for CentOS 6. (It may also be out of date.)
If you have RHEL or CentOS 5, you can find the specific link for your RPM here: http://dl.iuscommunity.org/pub/ius/stable/
Why do you need 5.3.8 specifically? The last version of 5.3 was 5.3.27. 5.3 is end-of-life. I would find a modern repo like remi and install 5.4 or later using yum

Running PHP 5.3 on CentOS 5.4 - fatal error Class 'PDO' not found

What is the best way to get PHP 5.3 up and running on CentOS 5.4.
My machine says I have PHP 5.3 installed but running into an issue with my script that says
Fatal error: Class 'PDO' not found in /var/www/html/lib/rb.php on line 45
It fails trying to new up a PDO class in the RedbeanPHP 3.0 lib.
How can I fix this missing PDO problem?
I tried to follow these instructions:
from http://www.computingunplugged.com/issues/issue201102/00002619002
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# THIS LINE FAILED FOR ME
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
UPDATE
Someone removed their answer. It was good. I'm putting it back in with exact steps.
First I had to yum install php53u-devel
To quote "
You need the PDO extension. Usually the best way to install extensions is via PECL.
Before you can install any PECL extensions you need to install the php5-dev package
sudo pecl install pdo
sudo pecl install pdo_mysql
You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.
extension=pdo.so
extension=pdo_mysql.so
"
Now I get a mysql_query_missing when trying to run sudo pecl install pdo_mysql
and not sure how to get past this.
You'll have to install the php-pdo package as well.
Edit: Maybe this helps as well: How do I enable PDO using CentOS?
I have been successfully able to install PHP-5.3 on CentOS 5.4 Linux. I needed this to be able to successfully install and run Drupal 7 - which also worked out for me. Here are the details:
This is a copy of the answer I wrote up in ServerFault: https://serverfault.com/a/392168/29205
(...for my question: https://serverfault.com/questions/391772/php-xml-install-complains-of-dependency-php-common-but-this-is-already-installed/392168#392168 )
The solution is based on the accepted answer in:
https://serverfault.com/questions/391839/how-to-force-centos-yum-to-use-a-later-version-of-a-package-dependency-already-i
In summary: move to php5.3.
Reason: support for php5.2 as been removed owing to security issues as explained in that other question's accepted answer. This removal causes mismatch of the versions of the dependencies and therefore the error seen.
Background
I wanted to run Drupal 7 on a CentOS 5.4 machine. So I needed 5.3 version of PHP.
Here are the full working steps to upgrade to PHP 5.3 with working repositories as of May 24 2012 ( I provide comments preceded by # - you don't need these, just for your info)
# Comment: sites like http://www.computingunplugged.com/issues/issue201102/00002619001
# provide a good start for remedying the problem whereby we need 5.3 on CentOS 5.4 to run Drupal 7. But although their packages worked at the time, the links are now outdated, and updates to these are below.
# comment: (as of May 2012 - the following work, the reason for failures was use of 1) older packages no longer on the server and 2) change of address of one of the servers to dl.fedoraproject.org/pub/epel (credit to: http://osdir.com/ml/centos/2012-03/msg00057.html )
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-10.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
# After doing the above, php -v shows 5.3.x But on attempting to install Drupal 7 you may get complaint of something "Your PHP installation is too old 5.1.6 Drupal requires at least PHP 5.2.4. See the system requirements page for more information." and php.info shows the same
# The remedy is to simply restart your apache server
service httpd restart
# credit to following for suggesting service httpd restart :-
# https://serverfault.com/a/207806/29205
# https://serverfault.com/questions/207762/centos-updating-php-via-yum-doesnt-change-the-version-apache-uses
# Drupal 7 install on CentOS 5.4 worked after applying the above steps
# If your MySQL server is not running (check by ps -ef | grep mysql ) then you can run:
/etc/init.d/mysqld
# ...to start it, and to make sure it starts when the machine is restarted or cold booted:
chkconfig mysqld on

Categories