Home  >  Article  >  Backend Development  >  Example of installing CentOS6.5 with Redis in PHP development

Example of installing CentOS6.5 with Redis in PHP development

高洛峰
高洛峰Original
2017-03-19 13:28:201380browse

1.InstallationRedis

 1 wget http://download.redis.io/releases/redis-3.2.8.tar.gz 
 2 tar xzf redis-3.2.8.tar.gz  
 3 cd redis-3.2.8 
 4 make
 5 
 6 cd src  
 7 cp redis-server /usr/local/bin/  
 8 cp redis-cli /usr/local/bin/
 9 
10 mkdir /etc/redis  
11 mkdir /var/redis  
12 mkdir /var/redis/6379
13 cd ../
14 cp utils/redis_init_script
15 cp redis.conf /etc/redis/6379.conf
16 vim /etc/redis/6379.conf

vim /etc/redis/6379.conf, find the following code part, modify

daemonize to yes  
pidfile to /var/run/redis_6379.pid  
logfile to /var/log/redis_6379.log  
dir to /var/redis/6379  
maxmemory 268435456

The maxmemory setting here is 256mb. You can set it yourself according to your configuration. Set up startup: vim /etc/rc.d/rc.local, add the following code

/etc/init.d/redis_6379 start 

2. Install the Redis extension

yum install git
git clone git://github.com/owlient/phpredis
cd phpredis
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

3. Add: extension in php.ini =redis.so 

4. Add password protection to Redis.

First of all, based on security considerations, we need to set a password for redis, unless your redis port is closed.
vim /etc/redis/6379.conf
Find the line, remove the # in front, and add the redis password at the end
requirepass rds423fsadD
Just restart redis.
/etc/init.d/redis_6379 stop 

The above is the detailed content of Example of installing CentOS6.5 with Redis in PHP development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn