Thursday, July 22, 2010

COnfigur mysql and php in apache server

download php.net 
 
wget  php-5.3.2.tar.bz2 
 
tar jxvf php-5.3.2.tar.bz2 
 
cd php-5.3.2 
 
yum install libxml2-devel 
 
##./configure --with-apxs2=/usr/local/apache/bin/apxs --prefix=/usr/local/php

./configure --enable-cgi=/usr/local/php –with-apxs=/usr/local/apache/bin/apxs

 
 make && make install 
## if an error(no gcc found) occurs, install gcc-->      yum install gcc

 less INSTALL -->copy AddType application/x-httpd-php .php .phtml and paste in httpd.conf

AddType application/x-httpd-php .php .phtml


vi /usr/local/apache/conf/httpd.conf 
LoadModule php5_module modules/libphp5.so 
AddType application/x-httpd-php .php .phtml 
save and quit 
 
/usr/local/apache/bin/apachectl restart 
 
cd /usr/local/apache/htdocs  create phpinfo.php: 
echo ""

Type http://192.168.2.189/phpinfo.php

To link PHP & Mysql

 install mysql...... 
 
1)yum list | grep mysql........from the list tht appears..install the folowing files... 
 
  mysql.i386       mysql-server.i386      mysql-devel.i386.... 
 
 #yum install    mysql.i386   mysql-server.i386  mysql-devel.i386

# yum list | grep Mysql
# yum install mysql-connector-odbc.i386 php-mysql.i386
#./configure --with-apxs2=/usr/local/apache/bin/apxs --prefix=/usr/local/php  --with-mysql=/usr/local/bin/
# make && make install
#cd
#/usr/local/apache/bin/apachectl restart
#cd /usr/local/apache/htdocs
#vim mysqltxt.php

$dbhost = 'localhost';
$dbuser = 'john';
$dbpass = 'john';

$conn=mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql');

$dbname= 'school';
mysql_select_db($dbname);
$a='select * from student';
$res=mysql_query($a);
$row=mysql_fetch_row($res);
echo $row[0];
echo $row[1];
echo $row[2];
?>

#service mysqld start
#mysql
mysql>grant all privileges on school.* to john@localhost identified by 'john';
mysql>flush privileges;
mysql>\q

type http://192.168.2.189/mysqltxt.php
 
 

No comments:

Post a Comment