installation and use of Redis 4.0 and Php-redis extensions on Ubuntu16.04
Install Redis
$ wget http://download.redis.io/release-4.0.1.tar.gz #从官网下载Redis 4.0.1
$ tar-zxvf redis-4.0.1.tar.gz #解压到当前目录
$ cd redis-4.0.1 #进入解压后的文件夹
$ make #编译
$ src/redis-server #启动服务
To complete this installation. using Redis
Local use Redis
Enter the SRC directory inside the unpacked directory:
$/redis-cli CD redis-4.0.1/src
$.
You can start the Redis client, which does not describe the use of redis too much
remote use of Redis
When you telnet to the Redis host, if you do not make any modifications to the Redis configuration, you will report: (Error) DENIED Redis is running into protected mode is enabled ...
This is because Redis the default boot protection mode, only local connections are used, and if you want to use remote connections, you need to modify the configuration file as follows:
First open the Redis configuration file, which is the redis.conf of the unpacked directory
1. Locate the line of bind 127.0.0.1, comment it out, that is, #bind 127.0.0.1,
2. Find the line Protected-mode Yes, change Yes to No, that is, Protected-mode no
3. Find #requirepass foobared This line, remove the annotation, change the following parameter to the password you want, such as Requirepass 88888888 then start the service, it is important to remember to take the parameters, in the SRC directory, to perform
$/redis-server. /redis.conf
I think the third step should be OK, but if you set a password, execute it after the Redis client starts
Auth 88888888,
to use on PHP
$redis = new Redis () ',
$redis-> auth (' 88888888 ')
Here's one more thing to say about installing Php-redis extensions when you use PHP
Reference:
Http://www.cnblogs.com/redirect/p/6486356.html
http://blog.csdn.net/Up_Seeker/article/details/40709179
1. Download Php-redis
wget Https://github.com/github.com/nicolasff/phpredis/zipball/master-O Php-redis.zip
2. Extract to current directory
$ unzip Php-redis.zip
3. The next step is important to see what version of PHP you have, if you are a PHP 5.6 version, then execute:
$ sudo apt-get install Php5.6-dev
If you are a PHP 7.0 version, then execute:
$ sudo apt-get install Php7.0-dev
There are words, it depends on which one you use, are not, php5.6 to php7.0 on the 5.6, php7.0 on the installation of 7.0, if not, please own Google (Baidu), this is just my personal view.
4. Go to the unpacked directory and execute:
$ phpize #这个是php-dev tools for compiling extensions
5. Run the configuration file, generate makefile, this step corresponds to the third step of the PHP version, note the version number:
$ sudo./configure--with-php-config=/usr/bin/php-config5.6
If the PHP version is 7.0, then change it back to php-config7.0.
6. Execute make compile file, build shared library (such as redis.so)
$ sudo make
7. Installation
$ sudo make install
8. Create the Redis.ini under/etc/php/5.6/mod-available, which reads as follows:
; Configuration for PHP redis module
; priority=20
extension=redis.so
9. Link Creation
$ sudo ln-s/etc/php/5.6/mod-available/redis.ini/etc/php5/apache2/conf.d/20-redis.ini
10. Restart Apache
sudo service apache2 restart
11. Use PHP inside Phpinfo () to see if there are Redis extensions