啊里云centos7.6编译安装NGINX+PHP7+MariaDB+MEMCACHED

安装前准备

  • 修改终端命令行提示符
[root@iZuf60c5bxd15kr9gycvv6Z ~]# echo "export PS1='[\W]➔ '">>/root/.bash_profile && source /root/.bash_profile
  • 升级所有包同时也升级软件和系统内核(因电脑差异可能需要几分钟时间)
[~]➔ yum -y update
  • 删除系统默认数据库配置文件 及 卸载系统自带mariadb-libs 并 重启系统
[~]➔ rpm -e mariadb-libs-* --nodeps
[~]➔ reboot

安装MariaDB数据库

  • 安装依赖库
[~]➔ yum -y install gcc-c++ openssl-devel ncurses-devel bison
  • 创建用户组 及 数据库相关目录
[~]➔ yum -y screen
[~]➔ screen -R lnmp
[~]➔ groupadd -r mysql
[~]➔ useradd -r -g mysql -s /sbin/nologin -d /usr/local/mysql -M mysql
[~]➔ mkdir -p /usr/local/mysql
[~]➔ mkdir -p /data/mysql
[~]➔ chown -R mysql:mysql /data/mysql
  • 安装cmake
[~]➔ cd /usr/local/src
[src]➔ wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz
[src]➔ tar -zxvf cmake-3.15.2.tar.gz && cd cmake-3.15.2
[cmake-3.15.2]➔ ./bootstrap && gmake && gmake install
[~]➔ cd /usr/local/src
[src]➔ wget https://downloads.mariadb.org/interstitial/mariadb-10.4.8/source/mariadb-10.4.8.tar.gz
[src]➔ tar -zxvf mariadb-10.4.8.tar.gz && cd mariadb-10.4.8
  • 编译参数
#--------------------------------------------------------------------------
# 输入以下编译参数
#--------------------------------------------------------------------------
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DCMAKE_BUILD_TYPE=Release \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \
-DWITHOUT_TOKUDB=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STPRAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LOBWRAP=0 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
#--------------------------------------------------------------------------
# 如果编译失败请删除 CMakeCache.txt
[mariadb-10.4.8]➔ rm -f CMakeCache.txt
# 让指令重新执行,否则每次读取这个文件,命令修改正确也是报错
# cmake没问题,可以编译并且安装了
#--------------------------------------------------------------------------
- 开始安装 (#这个过程比较久,跟据电脑配制不同可能会有10-30分钟#)
[mariadb-10.4.8]➔ make && make install
  • 导入mysql系统表
[mariadb-10.4.8]➔ cd /usr/local/mysql/
[mysql]➔ scripts/mysql_install_db --user=mysql --datadir=/data/mysql
#--------------------------------------------------------------------------
#经过测试,mariadb-10.4 以上运行以上脚本会报以下错误
#--------------------------------------------------------------------------
chown: 无法访问"./lib/plugin/auth_pam_tool_dir": 没有那个文件或目录
Cannot change ownership of the './lib/plugin/auth_pam_tool_dir' directory
 to the 'mysql' user. Check that you have the necessary permissions and try again.
#--------------------------------------------------------------------------
#解决方法:
[mysql]➔ vi scripts/mysql_install_db
#找到483,484,493,494行 并注释掉代码即可
483   #chown $user "$pamtooldir/auth_pam_tool_dir" && \
484   #chmod 0700 "$pamtooldir/auth_pam_tool_dir"
.......
493     #chown 0 "$pamtooldir/auth_pam_tool_dir/auth_pam_tool" && \
494     #chmod 04755 "$pamtooldir/auth_pam_tool_dir/auth_pam_tool"
  • 复制配制文件
[mysql]➔ cp /usr/local/mysql/support-files/wsrep.cnf /etc/my.cnf
  • 编写服务脚本
[mysql]➔ hostname
xxxxxxxxxxxxxxxxxxxxxxx(此处会显示电脑名称,将此名称填写在下方PIDFile=/data/mysql/xxxxx.pid中)
[mysql]➔ vi /lib/systemd/system/mysql.service
#--------------------------------------------------------------------------
#输入以下代码
#--------------------------------------------------------------------------
[Unit]
Description=MySQL Community Server
After=network.target

[Service]
User=mysql
Group=mysql
Type=forking
PermissionsStartOnly=true
PIDFile=/data/mysql/************* YOU HOST NAME *************.pid
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecReload=/usr/local/mysql/support-files/mysql.server restart
ExecStop=/usr/local/mysql/support-files/mysql.server stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  • 设置服务
# 开机启动
[mysql]➔ systemctl enable mysql.service
# 启动服务
[mysql]➔ systemctl start mysql.service
# 停止服务
[mysql]➔ systemctl stop mysql.service
# 重启服务
[mysql]➔ systemctl restart mysql.service
# 杀死进程
[mysql]➔ pkill -9 mysql
  • 配置环境变量(以便在任何目录下输入mysql命令)
[mysql]➔ touch /etc/profile.d/mysql.sh
[mysql]➔ echo 'export PATH=$PATH:/usr/local/mysql/bin/' > /etc/profile.d/mysql.sh
[mysql]➔ chmod 0777 /etc/profile.d/mysql.sh
[mysql]➔ source /etc/profile.d/mysql.sh
  • 初始化MariaDB
# 运行MariaDB初始化脚本
[mysql]➔ ./bin/mysql_secure_installation

# --------------------------------------------------------------------------
# 根据相关提示进行操作
# 以下提示:
# --------------------------------------------------------------------------
Enter current password for root (enter for none):    输入当前root密码(回车)
Switch to unix_socket authentication [Y/n]           是否启用socket授权(n)
Change the root password? [Y/n]                      是否修改root用户密码?(Y)
New password:                                        输入新root密码(a123456)
Re-enter new password:                               确认输入root密码(a123456)
Remove anonymous users? [Y/n] Y                      删除匿名用户?(Y)
Disallow root login remotely? [Y/n] Y                不允许root登录远程?(Y)
Reload privilege tables now? [Y/n] Y                 现在重新加载权限表(Y)

#全部完成!如果你已经完成了以上步骤,MariaDB安装现在应该安装完成。
  • 创建外网可访问的管理员帐号(根据需要,请尽量保证密码的复杂性避免数据库外泄)
[mysql]➔ mysql -uroot -p
# 根据提示输入密码
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY 'your password' WITH GRANT OPTION;

安装NGINX

  • 创建用户组 及 网站目录
[~]➔ groupadd -r www
[~]➔ useradd -r -g www -s /sbin/nologin -d /usr/local/nginx -M www
[~]➔ mkdir -p /usr/local/nginx
[~]➔ mkdir -p /data/web
[~]➔ chown -R www:www /data/web

-下载安装包并解压

[~]➔ cd /usr/local/src
[src]➔ wget http://nginx.org/download/nginx-1.16.1.tar.gz
[src]➔ tar -zxvf nginx-1.16.1.tar.gz && cd nginx-1.16.1
  • 编译参数
#--------------------------------------------------------------------------
# 输入以下编译参数
#--------------------------------------------------------------------------
./configure \
--prefix=/usr/local/nginx \
--without-http_memcached_module \
--user=www  \
--group=www \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module
#--------------------------------------------------------------------------
# 如果看到以下说明则编译成功
Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
#--------------------------------------------------------------------------
  • 执行安装
[nginx-1.16.1]➔ make && make install
  • 编写快捷启动脚本
[nginx-1.16.1]➔ vi /lib/systemd/system/nginx.service
# --------------------------------------------------------------------------
# 输入以下代码
# --------------------------------------------------------------------------
[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  • 设置服务
# 开机启动
[nginx-1.16.1]➔ systemctl enable nginx.service
# 启动服务
[nginx-1.16.1]➔ systemctl start nginx.service
# 停止服务
[nginx-1.16.1]➔ systemctl stop nginx.service
# 重启服务
[nginx-1.16.1]➔ systemctl restart nginx.service
# 杀死进程
[nginx-1.16.1]➔ pkill -9 nginx
  • 配制NGINX
[nginx-1.16.1]➔ cd /usr/local/nginx/conf
[conf]➔ vi nginx.conf
# --------------------------------------------------------------------------
# 修改如下代码
# --------------------------------------------------------------------------
1. #user nobody; => #user www www;  #去除前面的#号 并将nobody改为 www www
2. pid logs/nginx.pid;              #去除前面的#号
3. #去除前面的#号
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
4. gzip  on;                        #去除前面的#号
5. server_tokens off;               #在gzip on下方加下一行(隐藏版本)
6. 将index.php设为默认页面
index  index.html index.htm index.php;
7. 使WEB环境支持PHP
location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
8. 在http{} 节点末尾添加 “include ../servers/*;” 使其方便添加虚拟多网站配制
  • 配制多网站(虚拟主机)
#在/usr/local/nginx/目录下创建servers目录存在不同网站配制
[conf]➔ mkdir /usr/local/nginx/servers && cd /usr/local/nginx/servers
#新增网站配制www.demo.com
[servers]➔ vi demo.vhost
#并粘贴以下代码(以下仅为示列配制,跟据自身要求做修改即可)
server {
    listen          80;
    server_name     www.demo.com demo.com;
    root            /data/web/demo/www;
    access_log      /data/web/demo/log/access.log main;
    error_log       /data/web/demo/log/error.log error;
    index           index.php;
    client_max_body_size    10m;

    #解析PHP代码
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    静态资源缓存10天
    location ~ .*\.(gif|jpg|jpeg|png|bmp|ico|swf|js|css|eof|ttf|ttc|otf|eof|woff|woff2|svg)$ {
        expires    10d;
        access_log  off;
        add_header Access-Control-Allow-Origin *;
    }
}

安装PHP7

  • 安装必要的相关扩展
[~]➔ yum -y install libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel readline-devel libxslt-devel
  • 安装libzip扩展
[~]➔ cd /usr/local/src && wget https://libzip.org/download/libzip-1.5.2.tar.gz
[src]➔ tar -zxvf libzip-1.5.2.tar.gz && cd libzip-1.5.2 && mkdir build && cd build && cmake .. && make && make install
  • 添加搜索路径到配置文件
echo '/usr/local/lib64'>>/etc/ld.so.conf && ldconfig -v

-下载安装包并解压

[~]➔ cd /usr/local/src
[src]➔ wget https://www.php.net/distributions/php-7.3.9.tar.gz
[src]➔ tar -zxvf php-7.3.9.tar.gz && cd php-7.3.9

-编译参数

#--------------------------------------------------------------------------
# 输入以下编译参数
#--------------------------------------------------------------------------
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www  \
--with-fpm-group=www \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared  \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-pcre-regex \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir  \
--with-freetype-dir \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets  \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-opcache
  • 开始安装
[php-7.3.9]➔ make && make install
  • 配置环境变量(以便在任何目录下输入php命令)
[php-7.3.9]➔ touch /etc/profile.d/php.sh
[php-7.3.9]➔ echo 'export PATH=$PATH:/usr/local/php/bin/' > /etc/profile.d/php.sh 
[php-7.3.9]➔ chmod 0777 /etc/profile.d/php.sh 
[php-7.3.9]➔ source /etc/profile.d/php.sh
  • 配制php.ini
[php-7.3.9]➔ cp php.ini-production /usr/local/php/etc/php.ini
[php-7.3.9]➔ vi /usr/local/php/etc/php.ini
# 做以下修改(内存,时区,隐藏版本号,开启opcache缓存)
# --------------------------------------------------------------------------
1.让到memory_limit = 128M                              修改为:memory_limit = 1024M
2.找到:;date.timezone =                               修改为:date.timezone = PRC
3.找到:expose_php = On                                修改为:expose_php = Off
4.找到:;opcache.enable=1                              修改为:opcache.enable=1
5.找到:;opcache.enable_cli=0                          修改为:opcache.enable_cli=1
6.在 Dynamic Extensions 代码块中添加 “zend_extension=opcache.so”
  • 配置php-fpm
[php-7.3.9]➔ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[php-7.3.9]➔ cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[php-7.3.9]➔ cp sapi/fpm/init.d.php-fpm /usr/local/php/bin/php-fpm
[php-7.3.9]➔ chmod 0777 /usr/local/php/bin/php-fpm
  • 创建服务
[php-7.3.9]➔ vi /lib/systemd/system/php-fpm.service
# --------------------------------------------------------------------------
# 输入以下代码
# --------------------------------------------------------------------------
[Unit]
Description=php-fpm
After=network.target

[Service]
Type=forking
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/bin/php-fpm start
ExecReload=/usr/local/php/bin/php-fpm restart
ExecStop=/usr/local/php/bin/php-fpm stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  • 启停服务
# 开机启动
[php-7.3.9]➔ systemctl enable php-fpm.service
# 启动服务
[php-7.3.9]➔ systemctl start php-fpm.service
# 停止服务
[php-7.3.9]➔ systemctl stop php-fpm.service
# 重启服务
[php-7.3.9]➔ systemctl restart php-fpm.service
# 杀死进程
[php-7.3.9]➔ pkill -9 php-fpm

安装PHP支持插件Memcache

  • 安装memcache软件
[~]➔ cd /usr/local/src
[src]➔ yum -y install libevent*
[src]➔ wget http://www.memcached.org/files/memcached-1.5.16.tar.gz
[src]➔ tar -zxvf memcached-1.5.16.tar.gz && cd memcached-1.5.16
[memcached-1.5.16]➔ ./configure --prefix=/usr/local/memcached
[memcached-1.5.16]➔ make && make install
  • 创建启动脚本
[memcached-1.5.16]➔ vi /usr/local/memcached/memcached
#--------------------------------------------------------------------------
# 输入以下代码(启动参数请在下面的脚本中修改,如端口,最大内存)
#--------------------------------------------------------------------------
#! /bin/sh
#
# chkconfig: - 55 45
# description:  The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached

# Source function library.
. /etc/rc.d/init.d/functions

HOST=127.0.0.1
PORT=11211
USER=root 
MAXCONN=1024
CACHESIZE=512
OPTIONS=""

if [ -f /etc/sysconfig/memcached ];then
    . /etc/sysconfig/memcached
fi

# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
    exit 0
fi

RETVAL=0

start () {
    echo "Starting memcached ..."
    # insure that /var/run/memcached has proper permissions
    chown $USER /usr/local/memcached/bin/memcached
    /usr/local/memcached/bin/memcached -d -l $HOST -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached.pid $OPTIONS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
}
stop () {
    echo "Stopping memcached ..."
    killproc memcached
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ] ; then
        rm -f /var/lock/subsys/memcached
        rm -f /var/run/memcached.pid
    fi
}

restart () {
    stop
    start
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
    stop
    ;;
    status)
    status memcached
    ;;
    restart|reload)
    restart
    ;;
    condrestart)
    [ -f /var/lock/subsys/memcached ] && restart || :
    ;;
    *)
    echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
    exit 1
esac
  • 脚本执行权限
[memcached-1.5.16]➔ chmod 0777 /usr/local/memcached/memcached
  • 脚本加入服务
[memcached-1.5.16]➔ vi /lib/systemd/system/memcached.service
# --------------------------------------------------------------------------
# 输入以下代码
# --------------------------------------------------------------------------
[Unit]
Description=memcached
After=network.target

[Service]
Type=forking
PIDFile=/var/run/memcached.pid
ExecStart=/usr/local/memcached/memcached start
ExecReload=/usr/local/memcached/memcached restart
ExecStop=/usr/local/memcached/memcached stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  • 启停服务
# 开机启动
[memcached-1.5.16]➔ systemctl enable memcached.service
# 启动服务
[memcached-1.5.16]➔ systemctl start memcached.service
# 停止服务
[memcached-1.5.16]➔ systemctl stop memcached.service
# 重启服务
[memcached-1.5.16]➔ systemctl restart memcached.service
# 强杀进程
[memcached-1.5.16]➔ pkill -9 memcached
  • 为PHP7 增加memcache扩展支持 (官司网memcache-3.0.8暂时不支持PHP的编译)

官网memcache-3.0.8在编译的时候出现“php-smart_str.h”没有找到的错误!

但是我们可以在github里面找到pecl-memcache支持PHP7的分支,请按以下操作即可完成memcache中扩展安装

[memcached-1.5.16]➔ cd /usr/local/src/php-7.3.9/ext
# 如果已经安装git忽略yun install git
[ext]➔ yum install git
[ext]➔ git clone https://github.com/websupport-sk/pecl-memcache memcache
[ext]➔ cd memcache
[memcache]➔ yum -y install autoconf
[memcache]➔ /usr/local/php/bin/phpize
[memcache]➔ ./configure --with-php-config=/usr/local/php/bin/php-config
[memcache]➔ make && make install
  • 修改php.ini
[memcache]➔ vi /usr/local/php/etc/php.ini
# 在 Dynamic Extensions 代码块中添加如下扩展 "extension=memcache.so"

-重启php-fpm && nginx 完成安装

[memcache]➔ systemctl restart php-fpm.service && systemctl restart nginx.service

PHP安装redis扩展

-安装tcl依赖

[~]➔ cd /usr/local/src
[src]➔ wget https://downloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz
[src]➔ tar xzvf tcl8.6.9-src.tar.gz && cd ./tcl8.6.9/unix/
[unix]➔ ./configure
[unix]➔ make && make install

-安装redis

[~]➔ cd /usr/local/src
[src]➔ wget http://download.redis.io/releases/redis-5.0.5.tar.gz
[src]➔ tar -zxvf redis-5.0.5.tar.gz && cd redis-5.0.5
[redis-5.0.5]➔ make && make test
  • 创建存储redis文件目录将所需要的文件移到该目录下
[redis-5.0.5]➔ mkdir -p /usr/local/redis
[redis-5.0.5]➔ cp /usr/local/src/redis-5.0.5/redis.conf /usr/local/redis/
[redis-5.0.5]➔ cp /usr/local/src/redis-5.0.5/src/redis-cli /usr/local/redis/
[redis-5.0.5]➔ cp /usr/local/src/redis-5.0.5/src/redis-server /usr/local/redis/
  • 编辑redis.conf配制文件让redis可以在后台运行
[redis-5.0.5]➔ vi /usr/local/redis/redis.conf
# --------------------------------------------------------------------------
# 找到 “daemonize no” 修改为 “daemonize yes”
# 找到 “# maxmemory <bytes>” 修改为 “maxmemory 2147483648” (2G,跟据服务器配制适当填写)
# wq保存
# --------------------------------------------------------------------------
  • 创建服务
[redis-5.0.5]➔ vi /lib/systemd/system/redisd.service
# --------------------------------------------------------------------------
# 输入以下代码并保存
# --------------------------------------------------------------------------
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf         
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
  • 启停服务
# 开机启动
[redis-5.0.5]➔ systemctl enable redisd.service
# 启动服务
[redis-5.0.5]➔ systemctl start redisd.service
# 停止服务
[redis-5.0.5]➔ systemctl stop redisd.service
# 重启服务
[redis-5.0.5]➔ systemctl restart redisd.service
# 强杀进程
[redis-5.0.5]➔ pkill -9 redis
  • 为PHP安装redis扩展
[redis-5.0.5]➔ cd /usr/local/src/php-7.3.9/ext
[ext]➔ wget http://pecl.php.net/get/redis-5.0.2.tgz
[ext]➔ tar -zxvf redis-5.0.2.tgz && cd redis-5.0.2
[redis-5.0.2]➔ /usr/local/php/bin/phpize
[redis-5.0.2]➔ ./configure --with-php-config=/usr/local/php/bin/php-config
[redis-5.0.2]➔ make && make install
  • 修改php.ini
$ vi /usr/local/php/etc/php.ini
# --------------------------------------------------------------------------
# 并找到 Dynamic Extensions 节点在下方增加如下(最后一行为添加项)
# zend_extension=opcache.so
# extension=memcache.so
# extension=redis.so     <-添加些项
# --------------------------------------------------------------------------
  • 重启php-fpm && nginx 完成安装
[redis-5.0.2]➔ systemctl restart php-fpm.service && systemctl restart nginx.service
    原文作者:isyee
    原文地址: https://segmentfault.com/a/1190000011344106
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞