LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   apache, php, mysql on linux (https://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

jstephens84 07-11-2006 08:05 PM

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?

MrSako 07-12-2006 01:25 AM

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

jstephens84 07-12-2006 08:44 AM

try changing extension to = php_mysql.so

Edit = Sorry just remebered that is for windows.

jstephens84 07-12-2006 08:54 AM

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?

MrSako 07-12-2006 11:56 PM

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)

jstephens84 07-13-2006 08:42 AM

To install Apache and PHP download apache2.0.53 and php5

Install for Apache
Code:

tar -zxvf httpd2.versionNumber
./configure --prefix=/usr/local \ --enable-mods-shared=most \ --enable-modules=all
make
make install

Install for php
Code:

./configure --with-mysql \ --with-apxs=/usr/local/apache2/bin/apxs
make
make install

edit the apache's conf file and make the following edits. Make sure that under LoadModule you have the following LoadModule php5_module libexec/libphp5.so. Also If you are being prompted to download you php scripts make sure the following is in apache. Under ClearModule list the following should be there AddModule mod_php5.c

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
Tonight I will put the install instructions for mysql.

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.

MrSako 07-13-2006 08:39 PM

hey thanks i got apache and php installed now, just waiting for your next post :}

jstephens84 07-14-2006 09:26 AM

First did your installation go off with out any problems? Also can you post the information from the phpinfo().

jstephens84 07-14-2006 09:46 AM

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
make
make install

then su to root
Code:

mysql_install_db --user=mysql

MrSako 07-14-2006 05:35 PM

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

jstephens84 07-14-2006 06:12 PM

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.

MrSako 07-14-2006 07:25 PM

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?

jstephens84 07-14-2006 09:04 PM

Doesn't matter. are you doing ./configure

MrSako 07-14-2006 09:30 PM

yes, the file is extracted

i type

cd /home/mysql
./configure

jstephens84 07-14-2006 09:58 PM

does it say anything about being a binary installation.

MrSako 07-15-2006 02:02 AM

ooooooooooooooooooooooooooooo i figured out what i was doing wrong, i wasnt really in the right directory

i did ./configure and it said

Quote:

NOTE: This is a MySQL binary distribution. It's ready to run, you don't
need to configure it!

To help you a bit, I am now going to create the needed MySQL databases
and start the MySQL server for you. If you run into any trouble, please
consult the MySQL manual, that you can find in the Docs directory.

Installing all prepared tables
Fill help tables

To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h vps.mydomain.com password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
Starting the mysqld server. You can test that it is up and running
with the command:
./bin/mysqladmin version
Starting mysqld daemon with databases from /home/mysql/mysql-standard-5.0.22-linux-i686/data
STOPPING server from pid file /home/mysql/mysql-standard-5.0.22-linux-i686/data/vps.mydomain.com.pid
060715 03:10:22 mysqld ended
so it turns out its a binary. so i dont know what to do now

jstephens84 07-15-2006 05:21 AM

Ok here we go.
Code:

groupadd mysql
useradd -g mysql mysql
cd /usr/local
tar -zxvf < /path/to/mysql-VERSION-OS.tar.gz
cp mysql-version-OS.tar.gz /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql
chown -R root  .
chown -R mysql data
chgrp -R mysql .
bin/mysqld_safe --user=mysql &

this should get you going. Now this will be different due to the information will now be in /usr/local/mysql. Databases will not be in /var. However you can work around this and get your databases there but That is beyond me. It normally takes me sitting in front of the screen to do this. Any problems let me know.

MrSako 07-15-2006 01:22 PM

when i typed in the scripts/mysql_install_db part i got a bunch of this

Quote:

> scripts/mysql_install_db --user=mysql
Installing all prepared tables
Fill help tables
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_topic.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_topic.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_keyword.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_keyword.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_relation.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_relation.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
060715 14:21:33 [ERROR] ./bin/mysqld: Can't find file: './mysql/help_category.frm' (errno: 13)
and went over and on with a whole bunch of help related files with frm extensions but at the very bottom it prints out

Quote:

To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h vps.mydomain.com password 'new-password'
See the manual for more instructions.

NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the ./bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
im going ot keep fallowing the instructions but i just didnt expect that

also is this normal?

Quote:

> 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
060715 14:26:16 mysqld ended

jstephens84 07-15-2006 01:35 PM

Could you post your my.cnf file.

MrSako 07-15-2006 04:31 PM

i looked around for it, but i dont see where my "my.cnf" file is

jstephens84 07-15-2006 04:52 PM

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.

MrSako 07-15-2006 05:25 PM

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?

jstephens84 07-15-2006 05:37 PM

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.

MrSako 07-15-2006 08:56 PM

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

jstephens84 07-16-2006 12:50 AM

can you post the my.cnf file that is used? I think I came acrossed this error before.

MrSako 07-16-2006 12:49 PM

this is my.cnf which currently resides in /usr/local/mysql/my.cnf

http://rafb.net/paste/results/PVaFHx57.html

jstephens84 07-16-2006 01:45 PM

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
chgrp -R /usr/local/mysql/data mysql

the issue a mysql_install_db --user=mysql

MrSako 07-16-2006 02:06 PM

> chown -R /usr/local/mysql/data mysql
chown: `/usr/local/mysql/data': invalid user

but i did create the mysql user....

MrSako 07-16-2006 03:36 PM

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

MrSako 07-16-2006 04:26 PM

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

btmiller 07-16-2006 04:59 PM

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.

MrSako 07-16-2006 05:34 PM

do i install it instead of php and mysql or along with php and mysql?

and where do i get it?

jstephens84 07-16-2006 05:46 PM

Check to make sure in the phpinfo that it shows mysql and look into the php.ini to see if mysql module is loaded.

MrSako 07-16-2006 07:36 PM

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?

btmiller 07-16-2006 11:02 PM

Quote:

Originally Posted by MrSako
do i install it instead of php and mysql or along with php and mysql?

and where do i get it?

It goes along with PHP and MySQL. You can get it with "yum install php-mysql" (no quotes) generally.

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.