LAMP动静分离(分布式)部署

本文详细介绍了如何在主机上配置LAMP环境,包括安装和配置httpd、mysql、php,并通过apache服务实现动静分离。文章最后通过访问验证确保部署成功。
摘要由CSDN通过智能技术生成

环境:


保证防火墙和selinux已经关闭,如果没有关闭可执行systemctl stop firewalldsetseenforce 0来关闭

系统 主机名 IP 服务
CentOS 7 node1 192.168.207.129 httpd2.4
CentOS 7 node2 192.168.207.130 mysql5.7
RedHat 7 node3 192.168.207.131 php7.4

配置步骤:


1. 在主机node1上安装和配置httpd

配置yum源

//下载wget
[root@node1 ~]# rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
//下载Centos7的源
[root@node1 ~]# mv /etc/yum.repos.d/* /opt
[root@node1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@node1 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo
//配置Centos7的源
[root@node1 ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@node1 ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
//下载epel源
[root@node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@node1 ~]# yum clean all

安装开发工具包

[root@node1 ~]# yum groups mark install 'Development Tools'

创建apache服务的用户和组

[root@node1 ~]# useradd -r -M -s /sbin/nologin apache
[root@node1 ~]# id apache
uid=997(apache) gid=995(apache) groups=995(apache)

安装依赖包

[root@node1 ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++

下载并解压apr和apr-util

[root@node1 ~]# wget http://mirror.bit.edu.cn/apache/apr/apr-1.7.0.tar.gz
[root@node1 ~]# wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
[root@node1 ~]# tar xf apr-1.7.0.tar.gz
[root@node1 ~]# tar xf apr-util-1.6.1.tar.gz
[root@node1 ~]# ls
apr-1.7.0         apr-util-1.6.1
apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz

安装apr和apr-util

//安装apr
[root@node1 ~]# cd apr-1.7.0
[root@node1 apr-1.7.0]# sed -ri '/^(....\$RM."\$cfgfile")$/d' configure
[root@node1 apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@node1 apr-1.7.0]# make && make install

//安装apr-util
[root@node1 apr-1.7.0]# cd ../apr-util-1.6.1
[root@node1 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@node1 apr-util-1.6.1]# make && make install
[root@node1 apr-util-1.6.1]# cd

下载并编译安装httpd

[root@node1 ~]# wget https://mirror.bit.edu.cn/apache/httpd/httpd-2.4.43.tar.gz
[root@node1 ~]# tar xf httpd-2.4.43.tar.gz
[root@node1 ~]# cd httpd-2.4.43
[root@node1 httpd-2.4.43]# ./configure --prefix=/usr/local/apache \
--sysconfdir=/etc/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork
[root@node1 h
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值