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? |
Heja, what command did you give to get which error exactly?
Have you checked whether mysql is running? |
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 |
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.
|
Code:
;;;;;;;;;;;;;;;;;;;;;; |
You should find in their an option that says something like extension_DIR. You must set that to where your modules for php reside.
|
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. |
arrrg my extension_dir is correct, but it still deosnt work, what could it be?
|
have you restarted httpd. also check to make sure your extensions are at that location. could you post your whole php.ini file.
|
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 |
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 |
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> |
removed___
|
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. |
|
Sorry didn't check for that. Your php.ini file looks fine. Have you tried adding that mysql.so file to the include path and then restarting apache?
|
i just tried copying that so file into the include directory that the ini points to
i still get [client 24.163.113.48] PHP Fatal error: Call to undefined function mysql_connect() in /var/www/html/phpinfo.php on line 8 i also restarted apache |
try changing extension to = php_mysql.so
Edit = Sorry just remebered that is for windows. |
OK, Lets get back to basics. First was php with your system or did you install yourself? Second if you did complie the program yourself how did you do it? What version are you using?
|
i used yum to install both mysql and php, apache came pre installed when i ordered the VPS
php vesion 5 mysql version4 (would like it ot be 5 but yum doesnt have mysql 5) im thinking abuot deleting apache php and mysql and installing it all by hand from a manual is there a good place that would explain the how to for a complete beginner like myself? (i mean like almost line by line commands of every step) |
To install Apache and PHP download apache2.0.53 and php5
Install for Apache Code:
tar -zxvf httpd2.versionNumber Code:
./configure --with-mysql \ --with-apxs=/usr/local/apache2/bin/apxs Also add the following AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps edit the DirectoryIndex DirectoryIndex index.php index.htm index.html default.php check /usr/bin for apache2ctl if not there then issue the following command Code:
ln -s /usr/local/apache2/bin/apache2ctl /usr/bin/apache2ctl I really think you should compile them for your self. That way you will have a tighter control on where things are and how they are. |
hey thanks i got apache and php installed now, just waiting for your next post :}
|
First did your installation go off with out any problems? Also can you post the information from the phpinfo().
|
Just go here and download from the nearest mirror.
tar -zxvf mysql-version.tar.gz Then just do the following. Code:
./configure --prefix=/usr/local Code:
mysql_install_db --user=mysql |
i would prefer to use mysql 5 becasue on my development machine i use mysql 5
http://dev.mysql.com/downloads/mysql/5.0.html but i dont know which download i need |
http://dev.mysql.com/get/Downloads/M...r.gz/from/pick
Choose that one. Then use the same install instructions from other post. If it is a binary install then let me know. |
i feel dumb becasue i did the apache and php without much of any problem
everytime i use the configure command it says not found but i did ls and i see configure right there btw this is all in /home/mysql should i of done this in /usr/local? |
Doesn't matter. are you doing ./configure
|
yes, the file is extracted
i type cd /home/mysql ./configure |
does it say anything about being a binary installation.
|
ooooooooooooooooooooooooooooo i figured out what i was doing wrong, i wasnt really in the right directory
i did ./configure and it said Quote:
|
Ok here we go.
Code:
groupadd mysql |
when i typed in the scripts/mysql_install_db part i got a bunch of this
Quote:
Quote:
also is this normal? Quote:
|
Could you post your my.cnf file.
|
i looked around for it, but i dont see where my "my.cnf" file is
|
It should either be in /usr/local/mysql or /etc. It also maybe that you have to rename something like my-huge.cnf or my-small.cnf to my.cnf or my.conf. Can't remember off the top of my head.
|
i found the cnf files you were talking about,
/usr/local/mysql/mysql-test/std_data/ndb_config_mycnf1.cnf /usr/local/mysql/mysql-test/std_data/ndb_config_mycnf1.cnf /usr/local/mysql/support-files/my-huge.cnf /usr/local/mysql/support-files/my-innodb-heavy-4G.cnf /usr/local/mysql/support-files/my-large.cnf /usr/local/mysql/support-files/my-medium.cnf /usr/local/mysql/support-files/my-small.cnf what are the differences between them? and where do i place the one i want? |
This depends on how this machine will be used. If it is for development purposes then You may just want to go with my-small.cnf. If you are using this in a production environment then you may want to choose medium - huge. The difference is how much the optimization of each of them.
You will need to copy them probably to either /etc or /usr/local/mysql. I am probably going to say copy them to /etc. Then try to run mysql_install_db --user=mysql again. I am currently installing CentOS 4.3 on a test server at my house so once it finishes I will be able to get a better look at what is going on. |
i try putting it in /usr/local/mysql and /etc each time it did the same thing
> bin/mysqld_safe --user=mysql & Starting mysqld daemon with databases from /usr/local/mysql/data STOPPING server from pid file /usr/local/mysql/data/vps.myfomain.com.pid 060715 21:57:14 mysqld ended |
can you post the my.cnf file that is used? I think I came acrossed this error before.
|
this is my.cnf which currently resides in /usr/local/mysql/my.cnf
http://rafb.net/paste/results/PVaFHx57.html |
What are the permissions for /usr/local/mysql/data. Is mysql the owner and the group for that directory. If not then do the following to change the permissions on the folder.
Code:
chown -R /usr/local/mysql/data mysql |
> chown -R /usr/local/mysql/data mysql
chown: `/usr/local/mysql/data': invalid user but i did create the mysql user.... |
nevermind it seems it was just the wrong syntax
> chown -R mysql:mysql /usr/local/mysql/data > chgrp -R mysql /usr/local/mysql/data > mysql_install_db --user=mysql bash: mysql_install_db: command not found thats what i just did i also did this again no luck > bin/mysqld_safe --user=mysql & Starting mysqld daemon with databases from /usr/local/mysql/data STOPPING server from pid file /usr/local/mysql/data/vps.mydomain.com.pid 060716 16:39:27 mysqld ended |
ok i got mysql to start!!!!
idunno how but its running but unfourtnatly i still get this in my httpd error log [client 24.163.113.48] PHP Fatal error: Call to undefined function mysql_connect() in /var/www/html/phpinfo.php on line 8 |
Do you have the php-mysql RPM installed? That's all I've ever had to do to get PHP and MySQL working together on CentOS.
|
do i install it instead of php and mysql or along with php and mysql?
and where do i get it? |
Check to make sure in the phpinfo that it shows mysql and look into the php.ini to see if mysql module is loaded.
|
you mean this in the php.ini? extension=mysql.so
Configure Command './configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-pear=/usr/share/pear' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/etc/httpd/conf/magic' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' i noticed in this huge block it mentions "without mysql" i think thats related to the problem how do i make it say with? |
Quote:
Edit: This will give you the PHP4 that comes with CentOS. If you really want PHP5 you'll need to follow some of the directions given by others and compile it yourself. |
All times are GMT -5. The time now is 03:20 PM. |