CentOS 6下搭建LAMP环境

时间:2023-03-09 19:24:48
CentOS 6下搭建LAMP环境

第一步,使用Xshell管理工具连接远程服务器

CentOS 6下搭建LAMP环境

第二步,输入服务器账号密码登录远程服务器

CentOS 6下搭建LAMP环境

CentOS 6下搭建LAMP环境

如果centos内置的yum源可用的软件偏少或者版本过低,请更新!

首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)

cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

第三步,

3.1,安装Apache软件,安装完成,如下图所示:

yum install -y httpd

CentOS 6下搭建LAMP环境

3.2,设置Apache自启动

CentOS 6下搭建LAMP环境

3.3,启动Apache软件

CentOS 6下搭建LAMP环境

3.4,解决第一次启动时ServerName错误

CentOS 6下搭建LAMP环境

CentOS 6下搭建LAMP环境

操作完成后记得重启Apache服务器

CentOS 6下搭建LAMP环境

第四步:MySQL数据库安装

4.1,安装MySQL软件(客户端、服务器端、依赖库)

CentOS 6下搭建LAMP环境

4.2,设置mysql自启动

CentOS 6下搭建LAMP环境

4.3,启动mysql软件

CentOS 6下搭建LAMP环境

4.4,使用mysql指令进入MySQL数据库

CentOS 6下搭建LAMP环境

4.5,设置MySQL密码,并刷新权限

CentOS 6下搭建LAMP环境

CentOS 6下搭建LAMP环境

4.6,退出mysql,验证密码是否生效

CentOS 6下搭建LAMP环境

第五步,安装PHP,这里我安装的是PHP7

5.1,rpm 安装 Php7 相应的 yum源

CentOS/RHEL 7.x:

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x:
# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

5.2,yum安装php7

CentOS 6下搭建LAMP环境

5.3,重启Apache

CentOS 6下搭建LAMP环境

5.4,测试

CentOS 6下搭建LAMP环境

CentOS 6下搭建LAMP环境

浏览器测试一下,搞定!

CentOS 6下搭建LAMP环境

ps:如Navicat等管理工具连接不上,请修改防火墙配置!