Multiple PHP Versions - will not connect to database?

Installed php 5.4.16 to run side by side with the default php installed with centos 5/virtualmin, which is 5.2.17

Problem is whenever a site tries to connect to the database, it cannot connect.

Is there something I’m missing? If I set the php version back to 5.2.17 it works fine. However the problem is web applications being installed require php 5.3+ and mysql 5.1+

Any advice?


What’s the exact error you receive when trying to connect to the database?

Also, are you sure that with PHP 5.4, that the MySQL module is installed?


Hi Eric,

The exact error is: Database connection error (2): Could not connect to MySQL. This is with Joomla 2.5 (or 3.0).

There are no errors in apache’s error log

I believe the module for mysql is installed, see below for the installed modules:
bz2 calendar cgi-fcgi Core ctype curl
date dom ereg exif fileinfo filter
ftp gd gettext gmp hash iconv
imap json ldap libxml mbstring mcrypt
mhash mysql mysqli mysqlnd odbc openssl
pcntl pcre PDO pdo_mysql PDO_ODBC pdo_sqlite
Phar posix readline Reflection session shmop
SimpleXML soap sockets SPL standard sysvmsg
sysvsem sysvshm tokenizer wddx xml xmlreader
xmlrpc xmlwriter xsl zip lib

Any ideas? Thanks for the help :slight_smile:

Also, when attempting to install a fresh joomla installation, here’s the error it spits out at the database configuration page when trying to connect to the database:

Could not connect to the database. Connector returned number: Could not connect to MySQL.

also, i can connect to the mysql database via the command line with SSH by using for example:
mysql -h localhost -uUSER -pPASS testdb

in case it matters, this is using sql version 5.0.95

Also tried reinstalling php54* today, following the same instructions:

no dice… any help would be GREATLY appreciated :slight_smile:


Hmm, it’s tough to say what the problem there might be, I haven’t experienced that myself.

If what you’re after is PHP 5.3 – there is a version of that which comes with CentOS 5.6 and newer.

You can see the packages for it by running “yum search php53”.

You can install those in place of the various “php-*” packages that are currently installed.

I’m curious if perhaps that might work better than the version available in the Software Collections repository.


There has been some issues with the php54 provided by REMI. Redhat is going to maintain their own php54 for Redhat customers. So remi is only providing php54 for x86_64 on CentOS 5 & 6.

Run this command and post what comes back so we can see what php54 packages are installed

“rpm -qa | grep php54”

Ip86, here are the modules installed:

I cannot install php 5.3 unfortunately however as there are some scripts not compatible with 5.3, so I’d like to have 5.2 and 5.4 installed simultaneously with mysql 5.1 installed.

Any ideas? I unfortunately really need to make this happen

Eric, can you clarify something for me, is the repo on this guide NOT remi’s?


Correct, that is the Software Collection’s repository, it’s not the REMI repo.

That said, to my knowledge it’s the same package maintainer.

However, with Software Collections, the packages are designed to work side-by-side with those available in CentOS, whereas the PHP packages in the REMI repo are designed to replace them.


So what do I need to do to upgrade PHP 5.1.6 on my Centos 5.7 box with the latest Virtualmin? What if I need to reverse that and go back if something breaks? Sorry I’m not the greatest Linux guy so trying to cover the bases before I screw up. Thanks