LAMP的搭建(redhat 6为例)

 1)安装httpd php php-mysql mysql-server

[[email protected] ~]# yum install httpd php php-mysql mysql-server

LAMP的搭建(redhat 6为例)

启动mysqld服务

[[email protected] ~]# service mysqld start

LAMP的搭建(redhat 6为例)

 使用mysql命令测试命令行

LAMP的搭建(redhat 6为例)

 我们查看监听端口3306是否被监听

LAMP的搭建(redhat 6为例)

 然后重启httpd服务

LAMP的搭建(redhat 6为例)

是否有php5的模块

 LAMP的搭建(redhat 6为例)

 LAMP的搭建(redhat 6为例)

如果有我们进行测试

把默认的页面修改为.php的页面

LAMP的搭建(redhat 6为例)

然后我们编辑网页index.php文件为以下内容

<?php
  $link = mysql_connect('127.0.0.1','root','');
  if ($link)
        echo "OK";
  else
        echo "Failure";

  mysql_close();
  phpinfo();
?>

LAMP的搭建(redhat 6为例)

网页进入192.168.10.2查看是否存在OK,如果出现OK说明我们的Httpd与Mysql服务是可以连接的,

LAMP的搭建(redhat 6为例)我们把mysql服务关闭则出现失败的页面