#1.安装Apache
yum install httpd httpd-devel
#启动apache
/etc/init.d/httpd start
#设为开机启动:
chkconfig httpd on
#2.安装mysql
yum install mysql mysql-server mysql-devel
#启动mysql
/etc/init.d/mysqld start
#设置mysql密码(MySQL语句)
USE mysql;
UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
FLUSH PRIVILEGES;
#允许远程登录
mysql -u root -p
Enter Password: <your new password>
GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
#设为开机启动
chkconfig mysqld on
#3. 安装php
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
#启动apache服务
/etc/init.d/httpd start
#至此,LAMP搭建完毕,测试一下是否安装成功,若无法访问则执行第4步,防火墙配置:
#4. 防火墙配置
#a.添加.允许访问端口{21: ftp, 80: http, 3306:mysql}.
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
#b.关闭防火墙{不推荐}.
service iptables stop
#c.重启防火墙
service iptables restart
#d.永久关闭防火墙{不推荐}.
chkconfig --level 35 iptables off