Centos7.8 Yum安装 LNMP+Redis 过程

一、安装前准备

1.1 关闭 firewall:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
 

1.2 关闭 SELINUX

vi /etc/selinux/config
#SELINUX=enforcing #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效

1.3 更新 yum 源

yum update
 

1.4 安装需要的软件包

yum-util 提供yum-config-manager功能
yum install -y yum-utils
yum install -y epel-release
 

1.5 加入新 repo源

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
 

二、 安装 nginx

2.1 检查可用的 package

yum list --enablerepo=remi | grep nginx
![](image.png)
如果需要添加最新的 nginx 源
cd /etc/yum.repos.d

vim nginx.repo

nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

wq:

2.2 安装

yum -y install nginx

2.3 启动nginx

systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止
systemctl restart nginx.service #重启
systemctl enable nginx.service #设置开机启动
 

三、安装 PHP

3.1 添加 PHP 源

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

3.2 检查可用的 package

yum list --enablerepo=remi | grep php

3.3 安装 PHP 及组件

yum -y install php72-php php72-php-fpm php72-php-bcmath php72-php-gd php72-php-mbstring php72-php-mysql php72-php-pdo php72-php-mysqlnd php72-php-opcache php72-php-pecl-memcache php72-php-pecl-memcached php72-php-pecl-mcrypt php72-php-pecl-mysql php72-php-pecl-redis5 php72-php-json php72-php-pecl-swoole4 php72-php-pecl-zip php72-php-xml php72-php-opcache php72-php-pecl-apcu php72-php-pecl-jsond php72-php-gmp php72-php-process php72-php-pecl-imagick php72-php-devel php72-php-common php72-php-intl php72-php-pecl-jsond-devel php72-php-pear php72-php-pecl-crypto

3.4 设置软链

ln -s /usr/bin/php72 /usr/bin/php
ln -s /usr/bin/php72-cgi /usr/bin/php-cgi
ln -s /usr/bin/php72-phar /usr/bin/php-phar
ln -s /usr/bin/php72-pear /usr/bin/php-pear
ln -s /usr/lib/systemd/system/php72-php-fpm.service /usr/lib/systemd/system/php-fpm.service

3.5 重载damon-reload

systemctl daemon-reload

3.6 启动 PHP-FPM

systemctl start php-fpm.service
systemctl enable php-fpm.service
 

四、安装 Redis

4.1 检查可用 package

yum list --enablerepo=remi | grep redis
![](image1.png)
![](A501481BB3514F678536AFC5F037C357)

4.2 安装 redis

yum -y install redis
 

4.3 启动 并设置成开机启动

systemctl start redis.service
systemctl enable redis.service
 

请我喝杯咖啡吧~

支付宝
微信