LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-12-2013, 11:35 AM   #1
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 116

Rep: Reputation: 7
PHP / MySQL


Hi,

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 http://stackoverflow.com/questions/15346605/

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 http://pastebin.com/W4Lb1NpP (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!
 
Old 03-12-2013, 01:02 PM   #2
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
Hi,

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

Code:
yum install mysql-libs

/etc/init.d/httpd restart
 
Old 03-12-2013, 01:04 PM   #3
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 116

Original Poster
Rep: Reputation: 7
Package mysql-libs-5.5.23-1.fc15.x86_64 already installed and latest version
Nothing to do

:-(

But thanks anyway!
 
Old 03-13-2013, 12:01 AM   #4
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Have you installed?
Code:
yum install php php-mysql -y
 
Old 03-13-2013, 07:23 AM   #5
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 116

Original Poster
Rep: Reputation: 7
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.
 
Old 03-13-2013, 08:07 AM   #6
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Can you check following line in php.ini
Code:
extension=mysql.so
Code:
extension=mysqli.so
as well as following file in
Code:
/usr/lib64/php/modules/mysql.so
Code:
/usr/lib64/php/modules/mysqli.so
 
Old 03-13-2013, 08:22 AM   #7
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 116

Original Poster
Rep: Reputation: 7
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.

php.ini:
extension=/usr/lib64/php/modules/mysql.so
extension=/usr/lib64/php/modules/mysqli.so
extension=/usr/lib64/php/modules/mcrypt.so

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.
 
Old 03-13-2013, 08:31 AM   #8
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Check the mysql is running
Code:
$ netstat -lnp | grep :3306
It should give something like this
Code:
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      19480/mysqld
can you log-in on mysql prompt using
Code:
$ mysql -h localhost -u username-of-your-mysql-user -p
If
$ yum install php5-mysql
does not solve the issue, then
These are the common settings in php.ini for mysql
Code:
[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.connect_timeout = 60
mysql.trace_mode = Off

[MySQLi]
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.reconnect = Off
and these are settings of my.cnf
Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
max_allowed_packet=128M
symbolic-links=0
lower_case_table_names = 1 

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Restart apache and mysql both after any change in php.ini and my.cnf
 
Old 03-13-2013, 08:42 AM   #9
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 116

Original Poster
Rep: Reputation: 7
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.
 
Old 03-13-2013, 09:03 AM   #10
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Have you tried to upgrade your php version.
Can you try this
 
Old 03-13-2013, 10:21 AM   #11
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 116

Original Poster
Rep: Reputation: 7
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 libphp5.so
-rwxr-xr-x. 1 root root 3946640 May 9 2012 libphp5-zts.so

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

... (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.

Last edited by cheddarcheese; 03-13-2013 at 10:59 AM.
 
Old 03-13-2013, 05:01 PM   #12
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 116

Original Poster
Rep: Reputation: 7
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!
 
Old 03-14-2013, 12:18 AM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,349

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
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...
 
Old 03-14-2013, 12:22 AM   #14
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Have you tried
Code:
$ yum install httpd
$ systemctl enable httpd.service
$ systemctl start httpd.service
The output of
Code:
$ systemctl status httpd.service
should be like
Code:
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
 
Old 03-14-2013, 12:36 AM   #15
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
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
http://www.linuxquestions.org/questi...bit%5D-904449/
 
  


Reply

Tags
apache, mysql, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GameCP, MySQL, PHP Connect PHP to MySQL? armsman Linux - Software 1 09-15-2011 10:22 AM
PHP 5.1.6 & MySQL 5.0.34 connectivity test, php-mysql & libmysqlclient_15 kapshure Linux - Newbie 1 08-05-2010 07:11 PM
yum install php-mysql fails with mysql 5.1 - "Error: mysql conflicts with MySQL" rebelde Linux - Software 2 03-13-2009 10:32 AM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration