Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure redis on Ali CVM and add it to boot (recommended)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

System AliyunLinux

Install Redis (I installed redis under / alidata/server/redis)

Go to http://redis.io/download to download redis and transfer it to the server with the FTP tool or follow the steps written on the redis official website to operate wget http://download.redis.io/releases/redis-2.8.18.tar.gz// download tar xzf redis-2.8.18.tar.gz// extract cd redis-2.8.18 make// compilation

2. Configure Redis

Cp redis.conf / etc/redis.conf# copy a redis configuration file to the etc directory open the redis configuration file vi / etc/redis.conf modify whether daemonize yes# runs as a daemon dir / var/lib/redis/ cache storage location useradd redis# add redis user mkdir-p / var/lib/redis# create db folder chown redis.redis / var/lib/redis# db file here

Edit the startup script (found on the Internet)

# description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/alidata/server/redis-2.8.18/src/redis-server REDIS_CLI=/alidata/server/redis-2.8.18/src/redis-cli PIDFILE=/var/run/redis.pid CONF= "/ etc/redis.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 if ["$?" = "0"] then echo "Redis is running..." Fi; stop) if [!-f $PIDFILE] then echo "$PIDFILE exists, process is not running." Else PID=$ (cat $PIDFILE) echo "Stopping..." $REDIS_CLI-p $REDISPORT-a $AUTH SHUTDOWN sleep 2 while [- x $PIDFILE] do echo "Waiting for Redis to shutdown..." Sleep 1 done echo "Redis stopped" fi;; restart | force-reload) ${0} stop ${0} start;; *) echo "Usage: / etc/init.d/redis {start | stop | restart | force-reload}" > & 2 exit 1 esac

4. Add boot entry

Vi / etc/rc.d/rc.local

Increase

/ etc/init.d/redis start

5. Testing

Create a php file in your site directory

$redis = new Redis (); $redis- > connect ('127.0.0.1, 6379); $redis- > set (' test', '11111'); echo $redis- > get (' test')

All right, this is the end of the configuration of the redis, because my novice is also in the groping configuration, if there is something wrong, welcome to correct, grateful!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report