LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   apache, php, mysql on linux (http://www.linuxquestions.org/questions/linux-newbie-8/apache-php-mysql-on-linux-463023/)

MrSako 07-11-2006 01:12 PM

apache, php, mysql on linux
 
i have apache installed works great

i have php installed, my php scrpits online work great

mysql is installed. doesnt work with php though. i tried to run a php script that connects to my mysql database. on my error log it got that the connect command wasn't recognises. meaning mysql and php arent set up to work togethor properly

the php version is 5 and mysql version is 4

what config files and settings do should i look through to double check stuff is set right so that mysql will work wiht php?

muha 07-11-2006 01:32 PM

Heja, what command did you give to get which error exactly?
Have you checked whether mysql is running?

nickk 07-11-2006 01:55 PM

I was just about to post this exact same question. I think he means that he gets a
"Fatal error: Call to undefined function: mysql_connect() in /var/www/html/test/index.php" error. I have the exact same problem as I'm useless with Linux. In windows you just uncomment a line in php.ini to include the mysql module. How do you do this in linux (Red Hat enterprise) without recompiling php or apache?

Thanks,
Nick

jstephens84 07-11-2006 02:53 PM

That error normally means that you do not have the mysql module loaded for php. Can you post your php config file? Their was a change I had to make on my system to get it running right.

nickk 07-11-2006 03:20 PM

Code:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;  extension=modulename.extension
;
; For example:
;
;  extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here.  Specify the location of the extension with the
; extension_dir directive above.
                                                                                                                           
extension=mysql.so
                                                                                                                           
;;;;
; Note: For Red Hat Linux, packaged extension modules are now loaded via
; the ini files in the directory /etc/php.d.
;;;;

You see, mysql.so is included as a module and it does exist in the extension_dir but it still doesnt work

jstephens84 07-11-2006 03:25 PM

You should find in their an option that says something like extension_DIR. You must set that to where your modules for php reside.

jstephens84 07-11-2006 03:34 PM

Ok, so I think I found it. If you look at line 398 or close to it you will see extension_dir.
This should point to /usr/lib/php/extensions.(This is if you are using slackware.) I am not sure where Ubuntu and other distro's keep these modules. Just one suggestion. I would use myslqi. so your commands would be mysqli_connect(). mysqli has extended functionality.

nickk 07-11-2006 03:36 PM

arrrg my extension_dir is correct, but it still deosnt work, what could it be?

jstephens84 07-11-2006 03:58 PM

have you restarted httpd. also check to make sure your extensions are at that location. could you post your whole php.ini file.

MrSako 07-11-2006 05:43 PM

yes i hjave the same error

[client 24.163.113.48] PHP Fatal error: Call to undefined function mysql_connect() in /var/www/html/phpinfo.php on line 8

im going to try and add that line into my php ini

MrSako 07-11-2006 05:55 PM

ok i was given an error saying it cant find mysql.so in that directory.

in my ini file

extension_dir = "/usr/lib/php/modules"

i just checked that directory and nothing was in it.

so i searched the machine for mysql.so the only result was

/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/mysql.so

which cant be the same mysql.so for php im thuinking its probally something for perl

im confused of what to do.
(please dont confuse me with the other guy with the asme problem)

oh yeh, yes mysql is running and working. i even put a database and tables in it

jstephens84 07-11-2006 06:32 PM

MrSako copy over that mysql.so then restart your apache web server then see if it works.

Best way is to run the following script.
Code:

<html>
<head>
<title>PHP Apache Mysql Test</title>
</head>
<body>
<?php
phpinfo();
?>
</body>
</html>

It will tell you what all php has loaded.

MrSako 07-11-2006 06:42 PM

removed___

jstephens84 07-11-2006 07:37 PM

Well a couple of good things came out of this. One we know apache and php are working together. We also
know that php did not load the mysql.so . If you look under mime_magic it goes straight into the o's.
I am currently installing Debian on my Server at the house. Once it completes I may have a look to see
if I can tell of any differences from slackware. By the way What Distro do you have? Also can You post your whole php.ini file.

MrSako 07-11-2006 07:55 PM

im using centos like my name implies on the side

heres my php.ini

http://pastebin.ca/85545


All times are GMT -5. The time now is 02:54 AM.