redis以及redis的php扩展一键安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis以及redis的php扩展一键安装相关的知识,希望对你有一定的参考价值。

说明:脚本记录在此处只要是供自己部署环境使用

[[email protected]_82_178_centos ~]# cat redis_redis-php.sh

#!/bin/bash
/usr/bin/wget -P /tmp http://download.redis.io/releases/redis-3.2.12.tar.gz
cd /tmp
tar xf redis-3.2.12.tar.gz
cd /tmp/redis-3.2.12
make MANIFESTO=jemalloc
make PREFIX=/usr/local/redis install
echo "export PATH=/usr/local/redis/bin:$PATH" >> /etc/profile
source /etc/profile
[ ! -d /usr/local/redis/conf ]&&mkdir /usr/local/redis/conf -p
[ ! -d /data/redis ]&&mkdir /data/redis -p
[ ! -d /usr/local/redis/log ]&&mkdir /usr/local/redis/log  -p

if [ -s /usr/local/redis/conf/redis.conf ]; then
    mv /usr/local/redis/conf/redis.conf /usr/local/redis/conf/redis.conf.`date +%Y%m%d%H%M%S`.bak
    cp /tmp/redis-3.2.12/redis.conf /usr/local/redis/conf/
fi

 >/usr/local/redis/conf/redis.conf

cat << EOF > /usr/local/redis/conf/redis.conf
bind 127.0.0.1
protected-mode yes
port 10201
tcp-backlog 8192
timeout 300
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_10201.pid
loglevel warning
logfile "/usr/local/redis/log/10201.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data/redis/
slaveof 192.168.1.10 102098
masterauth YHu222tuEq
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
min-slaves-to-write 6
min-slaves-max-lag 30
requirepass  YHu222tuEq
maxclients 100000
maxmemory 8g
maxmemory-policy noeviction
maxmemory-samples 5
#appendonly yes
#appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 256
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 256
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

EOF
######
echo 8192 >/proc/sys/net/core/somaxconn
echo ‘vm.overcommit_memory = 1‘ >>  /etc/sysctl.conf
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo ‘redis-server /usr/local/redis/conf/redis.conf ‘  >>/etc/rc.local

echo ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled‘ >>/etc/rc.local
source /etc/profile
redis-server /usr/local/redis/conf/redis.conf

wget  -P /tmp   https://github.com/nicolasff/phpredis/archive/master.zip
cd /tmp/
unzip master.zip && cd phpredis-master
/usr/local/php/bin/phpize 
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
echo "extension = redis.so" >> /usr/local/php/etc/php.ini 
/usr/local/php/sbin/php-fpm -y /usr/local/php/etc/php-fpm.conf -t

以上是关于redis以及redis的php扩展一键安装的主要内容,如果未能解决你的问题,请参考以下文章

php安装redis扩展

php安装redis扩展

Redis以及Redis的php扩展安装无错版

mac 中安装redis 以及 安装php-redis扩展过程详细记录

windows下安装redis 以及phpredis的扩展 (windows redis php&php7)

windows下php7.1安装redis扩展以及redis测试使用全过程