web01、web02
1、使用官方仓库安装 Nginx

#检查/etc/fstab 有没有挂载/data目录,记得先注释,后面会重新指定静态文件目录挂载

#可能优先使用epel里的源,怎么确保我们配置的 官方优先。
[root@web01 ~]$yum -y install yum-plugin-priorities
[root@web01 ~]$ rpm -qa yum-plugin-priorities 
yum-plugin-priorities-1.1.31-54.el7_8.noarch

[root@web01 ~]$ cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo 
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
priority=1    #增加优先参数,使得官方源优先epel源。

#安装Nginx
[root@web01 ~]$ yum install nginx -y

2、配置Nginx进程运行的用户

[root@web01 ~]$ useradd -u1111 www -s /sbin/nologin -M 
[root@web01 ~]$ sed -i '/^user/c user www;' /etc/nginx/nginx.conf
[root@web01 ~]$ grep "^user" /etc/nginx/nginx.conf

3、启动Nginx,并将Nginx加入开机自启

[root@web01 ~]$ systemctl start nginx 
[root@web01 ~]$ systemctl enable nginx
[root@web01 ~]$ lsof -i:80 #查看端口对应的服务
[root@web01 ~]$ nginx -v #查看版本
nginx version: nginx/1.22.1
[root@web01 ~]$curl 192.168.238.5 # Welcome to nginx!表示正常

4、使用第三方扩展源安装php7.4

#安装PHP7.4 
安装php第三方官方yum源 
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y 
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y 
#安装yum-tools管理工具 
yum -y install yum-utils 
#启用PHP 7.4 Remi存储库 
yum-config-manager --enable remi-php74
#安装php扩展服务包 
rpm -e $(rpm -qa|grep php) 
yum install php74-php php74-php-cli php74-php-common php74-php-devel php74-php-embedded php74-php-gd -y
yum install php74-php-mcrypt php74-php-mbstring php74-php-pdo php74-php-xml php74-php-fpm php74-php-mysqlnd -y
yum install php74-php-opcache php74-php-pecl-memcached php74-php-pecl-redis php74-php-pecl-mongodb -y

[root@web02 ~]# php74 -v
PHP 7.4.21 (cli) (built: Jun 29 2021 15:17:15) ( NTS ) 

[root@web02 ~]# rpm -ql php74-php-fpm 
/etc/logrotate.d/php74-php-fpm 
/etc/opt/remi/php74/php-fpm.conf 
/etc/opt/remi/php74/php-fpm.d 
/etc/opt/remi/php74/php-fpm.d/www.conf

# 配置php-fpm用户与Nginx的运行用户保持一致 
[root@web01 ~]# sed -i '/^user/c user = www' /etc/opt/remi/php74/php-fpm.d/www.conf 
[root@web01 ~]# sed -i '/^group/c group = www' /etc/opt/remi/php74/php-fpm.d/www.conf 
[root@web01 ~]# egrep "^user|^group" /etc/opt/remi/php74/php-fpm.d/www.conf 
user = www 
group = www

# 启动
systemctl start php74-php-fpm
systemctl enable php74-php-fpm
ps -ef|grep php

#授权/data目录
chown -R www.www /data/
ll -d /data