How to compile and install php redis service
这篇文章主要介绍了关于php redis服务编译安装的方法,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
安装前准备
yum install gcc yum install gcc-c++ mkdir -p /data/pkg cd /data/pkg
下载源码包以及解压
wget http://download.redis.io/releases/redis-4.0.10.tar.gz tar -zxf redis-4.0.10.tar.gz cd redis-4.0.10
编译安装
make make install
make install 后,会在/usr/local/bin目录底下生成多个可执行文件。
redis-cli redis命令行操作工具 redis-benchmark redis性能测试工具 redis-check-aof 数据修复 redis-check-dump 检查导出工具 redis-sentinel redis哨兵 redis-server redis服务启动
配置前准备
mkdir -p /usr/local/redis/bin mkdir -p /usr/local/redis/etc mv /usr/local/bin/redis-* /usr/local/redis/bin/ ln -s /usr/local/redis/bin/{redis-cli,redis-server} /usr/local/bin
配置
cp redis.conf /usr/local/redis/etc cp sentinel.conf /usr/local/redis/etc ln -s /usr/local/redis/etc/* /usr/local/etc
修改配置文件
vim /usr/local/redis/etc/redis.conf #修改Redis配置文件,使Redis以后台进程的形式启动 将daemonize no这行修改为daemonize yes 取消requirepass foobared前的#注释,修改自己设置的密码
启动服务
/usr/local/bin/redis-server /usr/local/redis/etc/redis.conf ps -ef | grep redis netstat -tunpl | grep 6379
停止
pkill redis-server 或者 /usr/local/bin/redis-cli shutdown
将redis做成服务
复制脚本到/etc/rc.d/init.d目录
pkill redis-server cp /data/pkg/redis-4.0.8/utils/redis_init_script /etc/rc.d/init.d/redis
如果这时添加注册服务:
chkconfig --add redis
将报以下错误:
redis服务不支持chkconfig
为此,我们需要更改redis脚本。
更改redis脚本
vim /etc/rc.d/init.d/redis
看到的配置文件
#!/bin/sh #chkconfig: 2345 80 90 # 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 "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF & fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;; esac
和原配置文件相比:
1.原文件是没有以下第2行的内容的,
#chkconfig: 2345 80 90
2.原文件EXEC、CLIEXEC参数,也是有所更改。
EXEC=/work/redis/bin/redis-server CLIEXEC=/work/redis/bin/redis-cli
3.redis开启的命令,以后台运行的方式执行。
$EXEC $CONF &
4.将redis配置文件拷贝到/etc/redis/${REDISPORT}.conf
mkdir /etc/redis cp /usr/local/redis/etc/redis.conf /etc/redis/6379.conf
注册redis服务
chkconfig --add redis
启动redis服务
service redis start
将redis加入环境变量
vim /etc/profile export PATH="$PATH:/usr/local/redis/bin" source /etc/profile
测试启动redis客户端
redis-cli
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
The above is the detailed content of How to compile and install php redis service. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.
