: This article mainly introduces how to install the redis database and php-redis extension on CentOS7. if you are interested in the PHP Tutorial, refer to it. Redis
First install redis on the server
1. wget http://download.redis.io/redis-stable.tar.gz download redis source code
2. tar xvzf redis-stable.tar.gz unzip
3. cd redis-stable
4. problems may occur during make, and exceptions may occur to me.
Exception 1:
Make [2]: cc: Command not found
Cause of exception: gcc is not installed
Solution: yum install gcc-c ++
Exception 2:
Zmalloc. h: 51: 31: error: jemalloc/jemalloc. h: No such file or directory
Cause of exception: Some compilation dependencies or issues left behind by the original compilation
Solution: make distclean. Clean up and then make.
5. after cd src make is complete, go to src
6. make test I encountered another exception.
Exception:
Couldn't execute "tclsh8.5": no such file or directory
Cause of exception: tcl is not installed
Solution: yum install-y tcl
7. after make is successful, some executable files will be added to the src Directory: redis-server, redis-cli, and so on.
Run the cp command in the usr directory.
Cp redis-server/usr/local/bin/
Cp redis-cli/usr/local/bin/
Create a directory to store the configuration file.
Mkdir/etc/redis
Mkdir/var/redis
Mkdir/var/redis/log
Mkdir/var/redis/run
Mkdir/var/apsaradb for redis/6379
Find the configuration file template in the redis root directory and copy it to the following location.
Cp redis. conf/etc/redis/6379. conf
Use the vim command to modify
Daemonize yes sets the service to run in the background
Pidfile/var/redis/run/redis_62.16.pid # set the pid file
Logfile/var/redis/log/redis_62.16.log # set log file storage
Dir/var/redis/6379 # set the folder
8. run redis-server/etc/redis/6379. conf
9. use telnet to test whether the installation and startup are successful:
Enter redis-cli
If 127.0.0.1: 6379> is displayed, the installation is successful.
Redis runs successfully
Next, install the redis extension of php
1. wget https://codeload.github.com/nicolasff/phpredis/zip/master download extension
2. unzip master decompression
Cd phpredis-master entry
3./usr/bin/phpize view information (the environment is different and the phpize location is different. it is best to find the file location in whereis phpize ),
If "Can't find PHP headers in/usr/include/php" is reported, install yum install php-devel first.
4 .. /configure PS: My php is installed by default, if your php is not installed by default, you need to specify the -- with-php-config parameter to describe the location of your php-config file,
You can use find to find out this ~ For example, my./configure -- with-php-c/bin/php-config
5. make & make install PS: pay attention to your users and permissions ~
6. add the redis extension configuration in vim/etc/php. ini.
7. locate the extension_dir location and add the following content below: extension = redis. so
8. restart Apache # systemctl restart httpd. service
9. test whether php redis extension is successfully installed:
$ Redis = new Redis ();
$ Redis-> connect ('2017. 0.0.1 ', 127 );
$ Redis-> set ('test', 'Hello world! ');
Echo $ redis-> get ('test ');
?>
If hello world! is output successfully! It indicates the operation is successful. Ps. if not, you can temporarily disable the firewall!
This is an experiment I personally installed in centos7 based on feihi's article. it works well! This process is similar to him.
However, you may encounter other problems during the installation process. if this is the case, you can refer to Baidu for a reference. Due to problems
They are relatively simple, so there is no record here! If you have any questions, contact me!
SOURCE statement: Fei hi? CentOS7 install redis database and php-redis extension (http://blog.feehi.com/linux/88.html)
Copyright Statement: Hello, we are very happy to meet you on CSDN! Hope to make friends with you!
The above describes how to install the redis database and php-redis extension on CentOS7, including some content, and hope to help those who are interested in the PHP Tutorial.