Linux (centOS7) install Redis and PHP operations Redis____linux

Source: Internet
Author: User
Tags install php install redis

Linux Installation Redis

1. Pre-Installation Preparation (GCC installation)

Yum Install gcc-c++

2. Download the Redis to the/USR/LOCAL/SRC directory
CD/USR/LOCAL/SRC
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  #编译

Note: After make is finished, the compiled Redis service Redis-server will appear in the redis-2.8.17 directory, as well as the client program REDIS-CLI for testing, two programs are located in the installation directory SRC directory

4. Start Redis Service

CD src
./redis-server

Note:./redis-server & Run the Redis service in the background

Note The default configuration is used in the way the Redis service is started. We can also tell Redis to use the specified configuration file with the startup parameters, as follows:

./redis-server redis.conf

REDIS.CONF is the default configuration file, and we can use our own profile as needed.

Once the 5.redis service is started, we can interact with the test client redis-cli and the Redis service.

CD src
./redis-cli
127.0.0.1:6379>set Key Gentry
OK
127.0.0.1:6379> get key
"Gentry"

To this, Linux installs Redis to come to an ending ...


Next, install the Php_redis.dll extension to allow PHP to support Redis

1. Pre-installation Preparation (installation of php-devel)

Yum Install Php-devel

2. Install the extended sample into the/USR/LOCAL/SRC directory

CD/USR/LOCAL/SRC
wget https://github.com/phpredis/phpredis/archive/2.2.4.tar.gz  #下载扩展
tar zxf 2.2.4. tar.gz
cd phpredis-2.2.4 
/usr/bin/phpize  #phpize执行文件的路径
Note: Use Whereis phpize to view phpize paths before performing/usr/bin/phpize

3. To configure

./configure--with-php-config=/usr/bin/php-config
Before you proceed with the above command, you may also use Whereis php-config to view the Php-config path

#编译安装 make
&& make install
By this step, the Php-redis extension is complete ...

php load Redis extension

1. Enter php.ini configuration file

Vi/etc/php.ini
Add the following content to any row in php.ini
extension=redis.so
2. Save exit, restart Apache

Systemctl Restart httpd
3.phpinfo to see if the Redis was installed successfully (see the following style to prove that Redis installed successfully)


4. Enter/var/www/html to execute PHP code test Redis

$redis = new Redis ();
$redis->connect (' 192.168.1.249 ', 6379);
$redis->set (' key ', ' gentry ');
echo $redis->get (' key ');
Page can output gentry, everything is done ...


If you need Linux installation memcache:http://blog.csdn.net/gentry__/article/details/51933874


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.