Linux系统yum工具快速安装LAMP环境

匿名 (未验证) 提交于 2019-12-02 21:56:30

LAMP环境和软件版本

名称 版本号
linuxϵͳ CentOS release 6.8 (Final)
Apache httpd-2.2.15-69.el6.centos.x86_64
mysql mysql-server-5.1.73-8.el6_8.x86_64
php php-5.3.3-49.el6.x86_64

一、安装Apache

1、查看是否安装过Apache。
# rpm -qa | grep httpd

2、有就卸载httpd。
# yum remove -y httpd*

3、重新安装httpd。
# yum install -y httpd

4、查看启动状态。
# service httpd status

5、启动httpd。
# service httpd start

6、添加开机启动,设置启动级别,查看启动级别。
# chkconfig --add httpd
# chkconfig httpd on
# chkconfig --list httpd

7、临时关闭防火墙seLinux和临时清除iptables防火墙规则。
# setenforce 0
# iptables -F

8、永久关闭selinux 需编辑配置文件/etc/selinux/config,设置SELINUX=disabled,重启系统后生效。

9、设置iptables防火墙开放httpd 监听网络端口,并保存配置。
# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
# service iptables save

10、使用浏览器访问http://192.168.1.110/,显示如下界面,说明安装的Apache HTTP服务正常运行。

二、安装mysql数据库

1、查看是否安装过mysql。
# rpm -qa | grep mysql

2、有就卸载mysql。
# yum remove -y mysql*

3、重新安装mysql-server。
# yum install -y mysql-server

4、查看启动状态。
# service mysqld status

5、启动mysql。
# service mysqld start

6、添加开机启动,设置启动级别,查看启动级别。
# chkconfig --add mysqld
# chkconfig mysqld on
# chkconfig --list mysqld

7、设置mysql数据库root账号密码。
# mysqladmin -uroot password ‘yourpassword’

8、root账号登陆mysql。
# mysql -uroot -p

9、登陆mysql后设置数据库密码命令。
mysql> SET PASSWORD = PASSWORD(‘123456’)

10、查看数据库。
# show databases;

11、退出mysql数据库。
mysql> quit; 或 mysql> exit

12、如需远程连接mysql,请设置iptables防火墙开放mysqld监听网络端口,并保存配置。
# iptables -I INPUT -p udp --dport 3306 -j ACCEPT
# service iptables save

三、安装PHP

1、查看是否安装过php。
# rpm -qa | grep php

2、有就卸载php。
# yum remove -y php*

3、重新安装php。
# yum install -y php

4、创建文件/var/www/html/index.php,写入内容 “This is a php test.” 。使用浏览器访问http://192.168.1.110/index.php,如果输出写入内容,则说明php安装成功,如下图。

# touch /var/www/html/index.php
# echo “This is a php test.” > /var/www/html/index.php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!