文章目录
lamp平台构建
环境说明:
系统平台 | IP | 需要安装的服务 |
---|---|---|
centos8 redhat8 |
172.16.12.128 | httpd-2.4 mysql-5.7 php php-mysql |
lamp平台软件安装次序:
httpd --> mysql --> php
安装httpd
//YUM源配置
[root@cl ~]# cd /etc/yum.repos.d/
[root@cl ~]# rm -rf *
[root@cl ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@cl yum.repos.d]# ls
CentOS-Base.repo
[root@cl yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@cl yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@cl yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@cl yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@cl ~]# dnf clean all
[root@cl ~]# dnf makecache
//安装开发工具包
[root@cl ~]# yum groups mark install 'Development Tools'
//安装依赖包
[root@cl ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
//创建apache服务的用户和组
[root@cl ~]# useradd -r -M -s /sbin/nologin apache
//下载和安装apr以及apr-util
[root@cl ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
[root@cl ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
[root@cl ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
[root@cl ~]# tar xf apr-1.7.0.tar.gz
[root@cl ~]# tar xf apr-util-1.6.1.tar.gz
[root@cl ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
apr-1.7.0 apr-util-1.6.1
[root@cl ~]# cd apr-1.7.0
[root@cl apr-1.7.0]# vim configure
cfgfile="${ofile}T"
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile" //将此行加上注释,或者删除此行
[root@cl apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@cl apr-1.7.0]# make && make install
[root@cl ~]# cd apr-util-1.6.1
[root@cl apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@cl apr-util-1.6.1]# make && make install
//编译安装httpd
[root@cl ~]# wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
[root@cl ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
apr-1.7.0 apr-util-1.6.1 httpd-2.4.54.tar.gz
[root@cl ~]# tar xf httpd-2.4.54.tar.gz
[root@cl ~]# cd httpd-2.4.54
[root@cl httpd-2.4.54]# ./configure --prefix=/usr/local/apache \
> --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@cl httpd-2.4.54]# make && make install
//安装后配置
[root@cl ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@cl ~]# source /etc/profile.d/httpd.sh
[root@cl ~]# which httpd
/usr/local/apache/bin/httpd
[root@cl ~]# ln -s /usr/local/apache/include/ /usr/include/apache
[root@cl ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config
//配置apache开机自启
[root@cl ~]# cd /usr/lib/systemd/system
[root@cl system]# cp ssh