[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

apache+php+mysql problem



Hi,all

I followed the instruction to configure apache+php+mysql at http://www.hut.fi/~tkarvine/lamp-linux-apache-mysql-php.html.

|1.edit /etc/httpd/conf/httpd.conf|
Find the section about homepages by searching |ctrl-W| for public_html, then comment out the line with |UserDir disable| and remove the comment char "|#|" from the line
|UserDir public_html|
2.|/etc/init.d/httpd restart|
|3.|Create a directory for homepages. Home directory, public_html and all directories under public_html must be executable (x) by all, so that web server can access files under them if it knows their name. Files must be readable by the web server.


|cd $HOME|
|mkdir public_html|
|echo "my homepage" > public_html/index.html|
|chmod a+x $HOME $HOME/public_html|
|chmod a+r $HOME/public_html/index.html|

Now Apache is working. I can see the webpage from http://localhost/~username

4.create hello.php at |$HOME/public_html|
|<?php echo "Hello PHP World, 2+2 is " . (2+2); ?>
Text outside code block is printed normally to web page.

Php should work as well. I can see the result by connecting to http://localhost/~username/hello.php


5.create mysql datebase. ||mysql| ||> |USE test; SHOW tables; CREATE TABLE persons( name VARCHAR(50), email VARCHAR(50) ); SHOW tables; DESC persons; INSERT INTO persons VALUES('Tero Karvinen', 'karvinen at-sign iki.fi'); SELECT * FROM persons; INSERT INTO persons VALUES('Sample Person', 'recycle nosuch invalid'); SELECT * FROM persons; QUIT;

6.create ||$HOME/public_html/database.php, just copy and paste, save as database.php.


7. http://localhost/~username/database.php


|It works fine until the last step(7th step).I didn't get the correct result. Instead, I got an error

PHP database example - http://iki.fi/karvinen.

*Warning*: mysql_connect(): Access denied for user: 'root localhost' (Using password: NO) in */home1/dingli/public_html/database.php* on line *8*
Could not connect : Access denied for user: 'root localhost' (Using password: NO)



I think I might need to set the mysql password? But I have no idea what's going on of mysql since I'm new to mysql. Could anyone help me to figure out what's wrong? and how can I let php+mysql work? I put some useful info at the end.


My system is FC1 and here are the packages I installed:
$ rpm -aq | grep httpd
redhat-config-httpd-1.1.0-5
httpd-manual-2.0.47-10
httpd-2.0.47-10
$ rpm -aq | grep php
php-pgsql-4.3.4-1.1
phpMyAdmin-2.5.0-1rh
php-ldap-4.3.4-1.1
php-4.3.4-1.1
php-imap-4.3.4-1.1
php-odbc-4.3.4-1.1
php-mysql-4.3.4-1.1
$ rpm -aq | grep mysql
mod_auth_mysql-20030510-3
mysql-server-3.23.58-4
mysql-3.23.58-4
php-mysql-4.3.4-1.1

Thanks for any replies.;)

Ding



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]