How to compile and install the PHP Redis service

Source: Internet
Author: User
Tags php redis pkill redis server
This article mainly introduces the PHP Redis service compiled installation method, has a certain reference value, now share to everyone, the need for friends can refer to

Pre-Installation Preparation

Yum install gcc yum install gcc-c++ mkdir-p/data/pkgcd/data/pkg

Download the source package and unzip

wget http://download.redis.io/releases/redis-4.0.10.tar.gztar-zxf REDIS-4.0.10.TAR.GZCD redis-4.0.10

Compiling the installation

Makemake Install

After make install, multiple executables are generated under the/usr/local/bin directory.

REDIS-CLI                 redis Command-Line Operations Tool Redis-benchmark           redis Performance test Tool    redis-check-aof           data repair Redis-check-dump          Check Export tool Redis-sentinel            Redis Sentinel redis-server              Redis service startup

Pre-configuration Preparation

Mkdir-p/usr/local/redis/binmkdir-p/usr/local/redis/etcmv/usr/local/bin/redis-*/usr/local/redis/bin/ln-s/usr/ Local/redis/bin/{redis-cli,redis-server}/usr/local/bin

Configuration

CP redis.conf/usr/local/redis/etc CP sentinel.conf/usr/local/redis/etcln-s/usr/local/redis/etc/*/usr/local/etc

Modifying a configuration file

vim/usr/local/redis/etc/redis.conf# Modify the Redis configuration file so that Redis starts as a background process modify Daemonize No to daemonize Yes to cancel Requirepass Foobared before the # comment, modify the password you set

Start the service

/usr/local/bin/redis-server/usr/local/redis/etc/redis.confps-ef | grep REDISNETSTAT-TUNPL | grep 6379

Stop it

Pkill Redis-server or/USR/LOCAL/BIN/REDIS-CLI shutdown

Make Redis a service

Copy script to/etc/rc.d/init.d directory

Pkill Redis-servercp/data/pkg/redis-4.0.8/utils/redis_init_script/etc/rc.d/init.d/redis

If you add a registration service at this point:

Chkconfig--add Redis

The following error will be reported:

Redis service does not support Chkconfig

To do this, we need to change the Redis script.

Change Redis Script

Vim/etc/rc.d/init.d/redis

See the configuration file

#!/bin/sh #chkconfig: 2345 # simple Redis INIT.D script conceived to work on Linux systems # as it does use of the/    Proc FileSystem. redisport=6379 Exec=/usr/local/redis/bin/redis-server cliexec=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/ Redis_${redisport}.pid conf= "/etc/redis/${redisport}.conf" case "$" in start) if [-F $PIDFILE] t Hen echo "$PIDFILE exists, process is already running or crashed" else echo "Start     ing Redis server ... "$EXEC $CONF & fi;         STOP) if [!-F $PIDFILE] then echo ' $PIDFILE does not exist, process was not running " Else pid=$ (cat $PIDFILE) echo "Stopping ..." $CLIEXEC-P $REDISPORT s Hutdown while [-x/proc/${pid}] does echo "Waiting for Redis to Shutdo WN ... "Sleep 1 doNe echo "Redis stopped" FI;; *) echo "Please use Start or stop as first argument";; Esac

Compared to the original configuration file:
1. The original document does not have the contents of line 2nd below,

#chkconfig: 2345 80 90

2. The original file exec, cliexec parameters, is also changed.

Exec=/work/redis/bin/redis-server   CLIEXEC=/WORK/REDIS/BIN/REDIS-CLI

3.redis commands that are enabled to run in the background.

$EXEC $CONF &

4. Copy the Redis configuration file to/etc/redis/${redisport}.conf

Mkdir/etc/redis  cp/usr/local/redis/etc/redis.conf/etc/redis/6379.conf

Sign up for Redis services

Chkconfig--add Redis

Start Redis Service

Service Redis Start

Adding Redis to environment variables

Vim/etc/profile export path= "$PATH:/usr/local/redis/bin" Source/etc/profile

Test start Redis Client

Redis-cli

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.