在虚拟机里面做了一遍,实验成功后复制的命令:
yum -y install httpd
/etc/init.d/httpd restart
cd /var/www/html/ echo benwen > index.htmlelinks --dump
benwen
yum -y install mysql mysql-server
use test;
create table gya (name char(20), tel int, addr char(50));
mysql> desc gya;
+-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | name | char(10) | YES | | NULL | | | tel | int(11) | YES | | NULL | | | addr | char(50) | YES | | NULL | | +-------+----------+------+-----+---------+-------+ 3 rows in set (0.00 sec)yum -y install php
cd /etc/httpd/conf.dcd /etc/httpd/conf.d/
/etc/init.d/httpd restart
cd /var/www/html/
vim mysql.php
<?php
$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect:' . mysql_error()); }mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM gya");
while($row = mysql_fetch_array($result))
{ echo $row['name'] . " " . $row['tel']; echo "<br />"; } mysql_close($con); ?>yum -y php-mysql
81 yum -y install php-mysql 82 /etc/init.d/httpd restart 83 elinks --dump 84 history 85 elinks --dumpbenwen