-   Linux - Software (
-   -   PHP / MySQL (

cheddarcheese 03-12-2013 11:35 AM


I've been trying to find a solution to this for months, and even on here have previously asked a related question, but no joy so far. More detailed info, where I've also asked this question on StackOverflow is at

The machine in question is running Fedora 15, 64-bit; Apache 2.2.x; MySQL 5.5; PHP 5.3.

Each of MySQL, PHP, and Apache work fine on their own, and PHP with MySQL works fine from the command line, but it won't work with Apache. Anything I try to do with PHP/MySQL with Apache results in "PHP Fatal error: Call to undefined function mysql_connect()" errors in the Apache log.

FYI. There is only one version each of Apache, MySQL and PHP installed on the machine.

php -i (from the command line) shows that PHP is compiled with MySQL support. However, phpinfo() output via a webpage says that it is not compiled with MySQL support ... yet it's the same installation. Each correctly reports itself as using /etc/php.ini for its config.

I've restarted Apache more times than I recall (and also MySQL just in case); and I've also disabled SELinux and tried numerous other things, but all to no avail.

So, right now I'm trying to figure out how come php -i can report PHP as being configured with MySQL, while phpinfo() reports that it is not ... because if I can solve that then I'm sure I'll be on my way to resolving the problem.

FYI. A copy of the php.ini file is at (the lines loading the mysql and pdo extensions, etc, are commented out because the modules are already loaded).

Any assistance would be much appreciated; I seem to have tried everything!

blue_print 03-12-2013 01:02 PM


Make sure you have mysql-libs RPM installed. If not, install using yum or rpm and restart httpd service.


yum install mysql-libs

/etc/init.d/httpd restart

cheddarcheese 03-12-2013 01:04 PM

Package mysql-libs-5.5.23-1.fc15.x86_64 already installed and latest version
Nothing to do


But thanks anyway!

fortran 03-13-2013 12:01 AM

Have you installed?

yum install php php-mysql -y

cheddarcheese 03-13-2013 07:23 AM

Yep, those were already done.

Package php-5.3.13-1.fc15.x86_64 already installed and latest version
Package php-mysql-5.3.13-1.fc15.x86_64 already installed and latest version
Nothing to do


But thanks anyway.

fortran 03-13-2013 08:07 AM

Can you check following line in php.ini
as well as following file in



cheddarcheese 03-13-2013 08:22 AM

Yep, the modules exist, and are referenced with their full path name in php.ini, and (from the command line at least) PHP warns that they are already loaded anyway. I've tried with the lines in, and with commenting them out. From the command line it works fine with them commented out, but doesn't work either way via a web page.


There is a link to the php.ini I'm using in the original post, but I expect my addition of the full path names, which I tried yesterday, does not appear in there.

fortran 03-13-2013 08:31 AM

Check the mysql is running

$ netstat -lnp | grep :3306
It should give something like this

tcp        0      0      *                  LISTEN      19480/mysqld
can you log-in on mysql prompt using

$ mysql -h localhost -u username-of-your-mysql-user -p
$ yum install php5-mysql
does not solve the issue, then
These are the common settings in php.ini for mysql

mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.connect_timeout = 60
mysql.trace_mode = Off

mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.reconnect = Off

and these are settings of my.cnf

lower_case_table_names = 1


Restart apache and mysql both after any change in php.ini and my.cnf

cheddarcheese 03-13-2013 08:42 AM

Yep, there's no problem with MySQL: the machine is a database server and MySQL has worked on the machine for a couple of years with no problem; I use other scripting languages to access MySQL with no problem, and log into MySQL with no problem, and PHP can also use MySQL from the command line anyway.

Already checked $ yum install php-mysql ... latest everything installed.

php.ini ... (see link for the posted php.ini) but yes, everything is set to the default settings you listed, so far as I can see.

Apache has always been restarted after any changes to php.ini. Shouldn't need to restart MySQL if no changes to my.cnf, although I did the other day just in case it made a difference ... it didn't.

fortran 03-13-2013 09:03 AM

Have you tried to upgrade your php version.
Can you try this

cheddarcheese 03-13-2013 10:21 AM

Handy link, thanks.

Yeah, just tried updating all the php bits, and a couple of the modules were updated, but no difference. If I could do a completely new install of Apache and PHP I would do, but a lot of work has already been done with Apache, so I don't really want to mess with it.

However, FYI, I have noticed one difference between the parameters shown by php -i and phpinfo(), and that is the directory to scan for additional .ini files. This may well be relevant.

php -i shows /etc/php.d as the directory (which is correct), and where additional .ini files to load the modules do indeed exist.

However, phpinfo() shows /etc/php-zts.d as the directory, which doesn't even exist. Mind you, the mysql modules, as already discussed, are defined as extensions in php.ini anyway ... but maybe it's not finding other required extensions, which might be causing my issue?

Nonetheless, I cannot find where "/etc/php-zts.d" is being defined. It's not in php.ini, and I'm not sure where else it would be.

I see in /usr/lib64/httpd/modules/:
-rwxr-xr-x. 1 root root 3736368 May 9 2012
-rwxr-xr-x. 1 root root 3946640 May 9 2012

/etc/httpd/conf.d/php.conf shows:
<IfModule prefork.c>
LoadModule php5_module modules/
<IfModule worker.c>
LoadModule php5_module modules/

... (i.e. one for worker, or the other for prefork).

Tried switching Apache from prefork to worker (edited /etc/sysconfig/httpd), and restarted, but no difference.

cheddarcheese 03-13-2013 05:01 PM

Actually, got so fed up with this that I completely removed PHP from the machine, and tried to re-install (i.e. yum install php php-mysql ... etc).

However, even though PHP and associated modules install without any problem, Apache will no longer start once PHP is installed, even though it previously did.

* Restarting httpd (via systemctl): Job failed. See system logs and 'systemctl status' for details.

If I remove PHP again then Apache will start. There's nothing of note in the /var/messages log or systemctl.

So, I'm kind of worse off than I even was before; at least previously PHP was working with Apache, even if PHP with MySQL wasn't working ... but now I can't even get PHP on the machine without Apache failing.

Any suggestions appreciated!

chrism01 03-14-2013 12:18 AM

Actually, I'm a little surprised you can re-install that; Fedora 15 is 4 versions out of date & I thought they archived the old stuff immediately.
Are you sure you're getting the correct versions of everything?

TBH though, Fedora is effectively RH's R&D distro; its not designed to be stable and definitely not for prod work, that's why they don't support it.
If you want a RH style free prod OS, go Centos; a free rebuild of RHEL; latest is v6.4 (same as RHEL)

Apologies if you know all this already...

fortran 03-14-2013 12:22 AM

Have you tried

$ yum install httpd
$ systemctl enable httpd.service
$ systemctl start httpd.service

The output of

$ systemctl status httpd.service
should be like

httpd.service - LSB: start and stop Apache HTTP Server
Loaded: loaded (/etc/rc.d/init.d/httpd)
Active: active (running) since Sun, 22 Jan 2012 14:00:15 +0100; 12s ago
Process: 8175 ExecStart=/etc/rc.d/init.d/httpd start (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/httpd.service
├ 8180 /usr/sbin/httpd
├ 8183 /usr/sbin/httpd
├ 8184 /usr/sbin/httpd
├ 8185 /usr/sbin/httpd
├ 8186 /usr/sbin/httpd
├ 8187 /usr/sbin/httpd
├ 8188 /usr/sbin/httpd
├ 8189 /usr/sbin/httpd
└ 8190 /usr/sbin/httpd

fortran 03-14-2013 12:36 AM

You have got the same problem before in 2011. The error was same as well as distro was same.
If it has worked for you before, it can work for you again.
Try this

All times are GMT -5. The time now is 11:53 PM.