redhat启动php服务器,redhat系统安装配置Apache+MySQL+PHP服务器环境

$host = 'xxx.xxx.xxx.xxx';

$user = 'alan';

$passwd = 'password';

$db = 'test';

$conn = mysql_connect($host,$user,$passwd);

if (!$conn) {

die('Could not connect: ' . mysql_error());

}

echo "select data from MySQL
";

mysql_select_db($db, $conn);

$select_sql = "select * from login";

$result = mysql_query($select_sql);

echo "

uidtimetext

while ($row = mysql_fetch_array($result)) {

echo "

";

echo "

".$row['uid']."";

echo "

".$row['dt']."";

echo "

".$row['text']."";

echo "

";

}

echo "


";

echo "

Name:

text:

";

mysql_close($conn);

?>

insert.php

$host = 'xxx.xxx.xxx.xxx';

$conn = mysql_connect($host,$user,$passwd);

die('Could not connect: ' . mysql_error());

mysql_select_db($db, $conn);

$insert_sql = "insert into login(uid,dt,text) values('$_POST[uid]', $dt, '$_POST[text]')";

echo "SQL: ".$insert_sql."
";

if (!mysql_query($insert_sql, $conn)) {

die('Error: ' . mysql_error());

echo "1 record added.
";

1. 访问页面

567dd09151e9ece22b3c65ab8ad5ce14.png

2. 提交表单,执行一条sql插入语句

ba126ee6b197b746f7844cedeb2a735c.png

3. 返回页面刷新查看结果

c9964d20f006f5707a6087f185d9b8d6.png

相关配置与环境

Apache主配置文件:/etc/httpd/conf/httpd.conf

Apache主配置目录,可以将不同类型的配置分门别类放入这个目录中:/etc/httpd/conf.d/

Apache网站根目录:/var/www/html/

Apache日志文件目录:/var/log/httpd

MySQL的my.cnf配置文件:/etc/my.cnf

MySQL数据库文件位置:/usr/lib/mysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值