文章目录
lamp
1. lamp平台构建
环境说明:
系统平台 | IP | 需要安装的服务 |
---|---|---|
centos8 | 192.168.64.128 | httpd-2.4.54、mysql-5.7.38、php、php-mysq l |
lamp平台软件安装次序:
httpd --> mysql --> php
注意:php要求httpd使用prefork MPM
1.1安装httpd
yum源配置,可以使用阿里云的
[root@192 ~]# cd /etc/yum.repos.d/
[root@192 yum.repos.d]# rm -rf *
[root@192 yum.repos.d]# yum clean all
0 files removed
[root@192 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
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:--100 2495 100 2495 0 0 16201 0 --:--:-- --:--:-- --:--:-- 16201
[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 clean all
0 files removed
[root@192 yum.repos.d]#
安装 epel 配置包
[root@192 yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
CentOS-8.5.2111 - Base - mirrors.aliyun 5.5 MB/s | 4.6 MB 00:00
CentOS-8.5.2111 - Extras - mirrors.aliy 162 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream - mirrors.a 7.5 MB/s | 8.4 MB 00:01
epel-release-latest-8.noarch.rpm 406 kB/s | 24 kB 00:00
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Installing:
epel-release noarch 8-16.el8 @commandline 24 k
Transaction Summary
========================================================================
Install 1 Package
Total size: 24 k
Installed size: 34 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : epel-release-8-16.el8.noarch 1/1
Running scriptlet: epel-release-8-16.el8.noarch 1/1
Many EPEL packages require the CodeReady Builder (CRB) repository.
It is recommended that you run /usr/bin/crb enable to enable the CRB repository.
Verifying : epel-release-8-16.el8.noarch 1/1
Installed:
epel-release-8-16.el8.noarch
Complete!
[root@192 yum.repos.d]#
将 repo 配置中的地址替换为阿里云镜像站地址
[root@192 yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 8 - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
baseurl=https://mirrors.aliyun.com/epel/8/Everything/$basearch
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-8&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 8 - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
baseurl=https://mirrors.aliyun.com/epel/8/Everything/$basearch/debug
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-8&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 8 - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
baseurl=https://mirrors.aliyun.com/epel/8/Everything/source/tree/
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-8&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
[root@192 yum.repos.d]#
然后在清理一下缓存
[root@192 ~]# dnf clean all
18 files removed
建立缓存
[root@192 ~]# dnf makecache
CentOS-8.5.2111 - Base - mirrors.aliyun 1.5 MB/s | 4.6 MB 00:03
CentOS-8.5.2111 - Extras - mirrors.aliy 40 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream - mirrors.a 4.5 MB/s | 8.4 MB 00:01
Extra Packages for Enterprise Linux 8 - 5.6 MB/s | 13 MB 00:02
Extra Packages for Enterprise Linux Mod 2.1 MB/s | 1.0 MB 00:00
Metadata cache created.
[root@192 ~]#
安装依赖包
[root@192 ~]# dnf groups mark install 'Developmnt Tools'
Last metadata expiration check: 0:01:32 ago on Tue 02 Aug 2022 08:26:19 PM CST.
Error: Module or Group 'Developmnt Tools' does not exist.
[root@192 ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim wget
Last metadata expiration check: 0:03:48 ago on Tue 02 Aug 2022 08:26:19 PM CST.
Package libtool-2.4.6-25.el8.x86_64 is already installed.
Package gcc-8.5.0-3.el8.x86_64 is already installed.
Package gcc-c++-8.5.0-3.el8.x86_64 is already installed.
Package make-1:4.2.1-10.el8.x86_64 is already installed.
Package vim-enhanced-2:8.0.1763-16.el8.x86_64 is already installed.
Package wget-1.19.5-10.el8.x86_64 is already installed.
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Installing:
expat-devel x86_64 2.2.5-4.el8 base 55 k
openssl-devel x86_64 1:1.1.1k-5.el8_5 base 2.3 M
pcre-devel x86_64 8.42-6.el8 base 551 k
Upgrading:
cpp x86_64 8.5.0-4.el8_5 AppStream 10 M
gcc x86_64 8.5.0-4.el8_5 AppStream 23 M
gcc-c++ x86_64 8.5.0-4.el8_5 AppStream 12 M
gcc-gdb-plugin x86_64 8.5.0-4.el8_5 AppStream 118 k
libgcc x86_64 8.5.0-4.el8_5 base 79 k
libgomp x86_64 8.5.0-4.el8_5 base 206 k
libstdc++ x86_64 8.5.0-4.el8_5 base 453 k
libstdc++-devel x86_64 8.5.0-4.el8_5 AppStream 2.0 M
openssl x86_64 1:1.1.1k-5.el8_5 base 709 k
openssl-libs x86_64 1:1.1.1k-5.el8_5 base 1.5 M
Installing dependencies:
keyutils-libs-devel x86_64 1.5.10-9.el8 base 48 k
krb5-devel x86_64 1.18.2-14.el8 base 560 k
libcom_err-devel x86_64 1.45.6-2.el8 base 38 k
libkadm5 x86_64 1.18.2-14.el8 base 187 k
libselinux-devel x86_64 2.9-5.el8 base 200 k
libsepol-devel x86_64 2.9-3.el8 base 87 k
libverto-devel x86_64 0.3.0-5.el8 base 18 k
pcre-cpp x86_64 8.42-6.el8 base 47 k
pcre-utf16 x86_64 8.42-6.el8 base 195 k
pcre-utf32 x86_64 8.42-6.el8 base 186 k
pcre2-devel x86_64 10.32-2.el8 base 605 k
pcre2-utf16 x86_64 10.32-2.el8 base 229 k
pcre2-utf32 x86_64 10.32-2.el8 base 220 k
....
....
创建apache服务的用户和组
这里创建用户的时候就直接创建一个组
[root@192 ~]# useradd -r -M -s /sbin/nologin apache
[root@192 ~]#
下载和安装apr以及apr-util和httpd
[root@192 src]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
--2022-08-02 20:40:54-- https://downloads.apache.org/apr/apr-1.7.0.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1093896 (1.0M) [application/x-gzip]
Saving to: ‘apr-1.7.0.tar.gz’
apr-1.7.0.tar.gz 100%[=============>] 1.04M 28.1KB/s in 42s
2022-08-02 20:41:37 (25.4 KB/s) - ‘apr-1.7.0.tar.gz’ saved [1093896/1093896]
[root@192 src]#
[root@192 src]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
--2022-08-02 20:42:12-- https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554301 (541K) [application/x-gzip]
Saving to: ‘apr-util-1.6.1.tar.gz’
apr-util-1.6.1.ta 100%[=============>] 541.31K 21.4KB/s in 20s
2022-08-02 20:42:33 (27.0 KB/s) - ‘apr-util-1.6.1.tar.gz’ saved [554301/554301]
[root@192 src]#
[root@192 src]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
--2022-08-02 20:42:12-- https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554301 (541K) [application/x-gzip]
Saving to: ‘apr-util-1.6.1.tar.gz’
apr-util-1.6.1.ta 100%[=============>] 541.31K 21.4KB/s in 20s
2022-08-02 20:42:33 (27.0 KB/s) - ‘apr-util-1.6.1.tar.gz’ saved [554301/554301]
[root@192 src]# wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
--2022-08-02 20:43:03-- https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9743277 (9.3M) [application/x-gzip]
Saving to: ‘httpd-2.4.54.tar.gz’
httpd-2.4.54.tar. 100%[====