"Linux database" Redis installation configuration

Source: Internet
Author: User
Tags delete key php compiler php redis zts dotfiles redis server

One, Redis configuration

1. Download and install


$ wget http://download.redis.io/releases/redis-2.8.17.tar.gz$ tar xzf redis-2.8.17.tar.gz$ cd redis-2.8.17$ make
$ make Install


Redis executables are put to/usr/local/bin by default.

2. Download the configuration file and init startup script:

wget Https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server
wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf
sudo mv Redis-server/etc/init.d/redis-server
sudo chmod +x/etc/init.d/redis-server
sudo mv redis.conf/etc/redis.conf
3. Initialize user and log path

Before starting Redis for the first time, it is recommended that you create a separate user for Redis and create a new data and log folder

sudo useradd Redis
sudo mkdir-p/var/lib/redis
sudo mkdir-p/var/log/redis
sudo chown Redis.redis/var/lib/redis
sudo chown Redis.redis/var/log/redis
4, set the boot automatically start, shut down automatically

sudo update-rc.d redis-server defaults
5. Start Redis:

Sudo/etc/init.d/redis-server start


6. Start the Client connection:

$ redis-cli
Redis> set Foo Bar
Ok
Redis> get foo

"Bar"

Reference Address: Http://redis.io/download


If you do not open the Redis service, you may see the following error :


Uncaught exception ' redisexception ' with message ' Redis server went away


CentOS command to start Redis service

cd/usr/local/bin/

sudo./redis-server


Now execute PHP redis.php will error CALSS Redis not found

Need to install a phpredis extension

Download: http://dl.dbank.com/c0u193fjey#

/usr/local/php/bin/phpize

./configure--with-php-config=/usr/local/php/bin/php-config

Make && make install

Vi/etc/php.d/redis.ini

Extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/redis.so

This step depends on your own PHP compiler parameters--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D this to decide where to add redis.so.


The most important step in Phpredis extended installation:

sudo vi/usr/local/php/lib/php.ini

Then look for:/extension

When you find the following location, add the extension=redis.so

              Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613"
extension=memcache.so
extension=memcached.so
extension=pdo_mysql.so
extension=censoring.so
extension=curl.so
extension=zlib.so
extension=mysql.so
extension=gd.so
extension=triefind.so
extension=kwordfilter.so
extension=xhprof.so
extension=pcntl.so
extension=redis.so

Finally, restart the Redis service

cd/usr/local/bin/

sudo./redis-server



PHP clears Redis database

//删除当前数据库中的所有Key$redis->flushdb ();//delete key from all databases $redis->flushall ();



"Linux database" Redis installation configuration

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.