I have encountered various installation tutorials on the Internet.
After two days, I finally got this thing done,
Here, we will summarize some unavoidable detours.
The php installation directory lacks folders! After installing phpredis, phpinfo has no redis extension! You may be able to solve your problem!
The following marked in red is where I got stuck for a long time.
1. install php (If php is faulty, delete and reinstall it)
* 1, first download php source code from the official website http://cn2.php.net/downloads.php decompress,
* 2. Compile and install php (make install requires root)
# Cd/php-NN (PHP extract directory, that is, the source code directory)
#. /Configure -- prefix =/usr/local/php -- with-mysql = mysqlnd -- with-mysqli = mysqlnd -- with-pdo-mysql = mysqlnd -- with-iconv-dir --- freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir -- enable-xml -- disable-rpath -- enable-bcmath -- enable- shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- with-mcrypt -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-gd -- enable-gd- native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- enable-ftp -- with-apxs2 =/usr /local/apache2/bin/apxs
(* Note that the configuration in this step requires many parameters. Otherwise, the installation directory after make install will lack many folders.
During config execution, check whether the last step has an error. If yes, it indicates that some php packages are missing.
For example, jpeg, png, and prce. Copy the error to google and download the corresponding package .)
# Make
# Make install (after this command is executed, the system will create the php installation directory under/usr/local)
At this point, you need to pay attention to the two directories, one is the php source code directory (which should be under/home/xxx), and the other is the php installation directory (under/usr/local)
* 3. Configure php. ini
# Cp php. ini-development/usr/local/lib/php. ini (don't forget)
# Vim/usr/local/lib/php. ini
Add a sentence to the statement (which can be used wherever possible. The online statement is to add [redis], which is actually the same ):
Extension = redis. so
Ii. Install redis
* 1. Download redis
# Wget http://redis.googlecode.com/files/redis-2.4.17.tar.gz
* 2. Install
# Cd./redis-NN
# Make
In this way, redis is installed.
You can open redis through/src/redis-server
Iii. Extend the php redis Module
* 1. Go to https://github.com/nicolasff/phpredis/to download the latest phpredisversion.
* 2. decompress the compressed package to ext in the php source code directory, that is,/home/xxx/php-NN/ext/phpredis.
# Mv phpredis-NN php-NN/ext/phpredis
* 3. Add phpredis to the php extension module.
#/Usr/local/php/bin/phpize (if configure does not add enough parameters during php compilation, phpize may be missing in the directory)
#./Configure -- with-php-config =/usr/local/php/bin/php-config (the following parameters are also important)
# Make
# Make install
* 4. Restart the server (apache or nginx)
In this way, you can see the redis extension in phpinfo.
Open redis (/src/redis-server)
Run the following code to test whether the job can be performed:
<? Php
$ Redis = newRedis ();
$ Redis-> connect ('2017. 0.0.1 ', 127 );
$ Redis-> set ('name', 'xxx ');
Echo $ redis-> get ('name ');
?>
If Fatal error: Uncaught exception 'redisexception' with message 'redis server went away 'occurs, it is because you have not enabled Redis.
Finally, I hope you can solve your problems as soon as possible!
Redis details: click here
Redis: click here
Recommended reading:
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Redis. conf