搭建 LAMP 服务
搭建 MySQL 数据库
安装 MySQL
使用 yum
安装 MySQL:
yum install mysql-server -y

安装完成后,启动 MySQL 服务:
service mysqld restart

设置 MySQL 账户 root 密码:[?]
/usr/bin/mysqladmin -u root password 'Password'
下面命令中的密码是教程为您自动生成的,为了方便实验的进行,不建议使用其它密码。如果设置其它密码,请把密码记住。
安装 Apache 服务
安装 Apache
使用 yum
安装 Apache
yum install httpd -y

启动 Apache 服务:
service httpd start

安装 PHP
安装 PHP 和 PHP-MYSQL 支持工具:
使用 yum
安装 PHP:[?]
yum install php php-mysql -y

CentOS 6 默认已经安装了 php-mysql,下面命令执行的可能会提示已经安装。
检查安装是否成功
检验 PHP 是否安装成功
我们在 /var/www/html 目录下创建一个info.php文件来检查php是否安装成功,示例代码参考如下


示例代码:/var/www/html/info.php
<?php phpinfo(); ?>
重启 Apache 服务:
service httpd restart

此时,访问 http://<您的 IP 地址>/info.php 可浏览到我们刚刚创建的 info.php 页面了
完成实验
恭喜!您已经成功完成了搭建 LAMP 服务器
。