环境:
保证防火墙和selinux已经关闭,如果没有关闭可执行
systemctl stop firewalld
和setseenforce 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