LAMP 架构介绍及环境搭建
LAMP分别代表什么?
- L代表服务器操作系统使用Linux
- A代表网站服务使用的是Apache软件基金会中的httpd软件
- M代表网站后台使用的数据库是MySQL数据库
- P代表网站是使用PHP/Perl/Python等语言开发
LAMP平台构建
环境说明:
系统平台 | IP | 需要安装的服务 |
---|---|---|
Centos8 | 192.168.174.164 | httpd-2.4 mysql-5.7 php php-mysql |
lamp平台软件安装次序:
httpd–>mysql–>php
注意:php要求httpd使用prefork MPM
安装httpd
//配置yum源
[root@192 ~]# cd /etc/yum.repos.d/
[root@192 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2495 100 2495 0 0 12230 0 --:--:-- --:--:-- --:--:-- 12230
[root@192 yum.repos.d]# ls
CentOS-Base.repo
[root@192 yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@192 yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@192 yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@192 yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
//安装开发工具包
[root@192 ~]# yum groups mark install 'Development Tools'
//创建apache服务的用户和组
[root@192 ~]# useradd -r -M -s /sbin/nologin apache
[root@192 ~]# id apache
uid=995(apache) gid=992(apache) groups=992(apache)
//安装依赖包
[root@192 ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
//安装vim编辑工具、make、wgte。
[root@192 ~]# dnf -y install vim make wget
//下载和安装apr以及apr-util和httpd
[root@192 ~]# cd /usr/src/
[root@192 src]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
[root@192 src]# ls
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz debug httpd-2.4.54.tar.gz kernels
[root@192 src]# tar xf apr-1.7.0.tar.gz
[root@192 src]# tar xf apr-util-1.6.1.tar.gz
[root@192 src]# cd apr-1.7.0/
[root@192 apr-1.7.0]# vim configure
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
#$RM "$cfgfile" //将此行加上注释,或者删除此行
[root@192 apr-1.7.0]# ./configure --prefix=/usr/local/apr //配置
[root@192 apr-1.7.0]# make && make install //编译安装
[root@192 apr-1.7.0]# cd /usr/src/apr-util-1.6.1/
[root@192 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@192 apr-util-1.6.1]# make && make install
[root@192 src]# tar xf httpd-2.4.54.tar.gz
[root@192 src]# cd httpd-2.4.54/
[root@192 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@192 httpd-2.4.54]# make && make install
[root@192 ~]