Home >Backend Development >PHP Tutorial >CentOS7 installs redis database and php-redis extension

CentOS7 installs redis database and php-redis extension

WBOY
WBOYOriginal
2016-08-08 09:19:121077browse
redis
First install redis into the server
1.wget http://download.redis.io/redis-stable.tar.gz Download the redis source code
2. tar xvzf redis-stable.tar.gz Unzip
3. cd redis-stable
4.make There may be problems when making, and mine has an exception
Exception 1:
make[2]: cc: Command not found
Exception reason: gcc is not installed
Solution: yum install gcc -c++
Exception 2:
zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory
Exception reason: some compilation dependencies or problems left over from the original compilation
Solution: make distclean. Clean it up and then make again.
5.cd src After make, enter src
6.make test I encountered exception a again
Exception a:
couldn't execute “tclsh8.5″: no such file or directory
Exception reason: tcl is not installed
Solution: yum install -y tcl
7. After make is successful, there will be some more executable files in the src directory: redis-server, redis-cli, etc.
Use the cp command to copy to the usr directory and run it.
cp redis-server /usr/local/bin/
cp redis-cli /usr/local/bin/
Then create a new directory to store the configuration file
mkdir /etc/redis
mkdir /var/redis
mkdir /var/redis /log
mkdir /var/redis/run
mkdir /var/redis/6379
Find the configuration file template in the redis decompression root directory and copy it to the following location.
cp redis.conf /etc/redis/6379.conf
Modify through vim command
daemonize yes The first is to set the service to run in the background
pidfile /var/redis/run/redis_6379.pid #Set the pid file
logfile /var/ redis/log/redis_6379.log #Set the storage of log files
dir /var/redis/6379 #Set the folder
8.redis-server /etc/redis/6379.conf Run redis
9. Use telnet to test whether it is installed And the startup is successful:
Enter redis-cli directly
If 127.0.0.1:6379> appears, it means 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 Unzip
cd phpredis-master Enter
3./usr/bin/phpize View information (the environment is different, the location of phpize is also different, it is best whereis phpize Find the file location),
If it reports Can't find PHP headers in /usr/include/php, install yum install php-devel first
4. ./configure PS: My php is installed by default, if your php is not For the default installation, you need to specify the --with-php-config parameter to indicate the location of your php-config file.
You can use find to find it~ For example, mine is like this./configure --with-php -c/bin/php-config
5.make && make install PS: Pay attention to your user and permissions here~
6.vim /etc/php.ini Add redis extension configuration
7. Find the location of extension_dir below Add the following content: extension=redis.so
8. Restart Apache #systemctl restart httpd.service
9. Test whether the php redis extension is successfully installed:
$redis = new Redis();
$redis-> ;connect('127.0.0.1',6379);
$redis->set('test','hello world!');
echo $redis->get('test');
?>

If hello world! is successfully output, it means success. ps, if that doesn’t work, you can temporarily turn off the firewall first!

I refer to Feihi’s article and personally installed it experimentally under centos7, and the effect is good! This process is roughly similar to his

, but there will be other problems encountered during the installation process. For this, you can find the reference answer on Baidu. Because the problems

are relatively simple, they are not recorded here! If you don’t understand anything, you can contact me!

Source statement: Fei Hi ? CentOS7 installs redis database and php-redis extension (http://blog.feehi.com/linux/88.html)

Copyright Statement: Hello, I am very happy to meet you on CSDN ! Hope to make friends with you all!

The above introduces the installation of redis database and php-redis extension on CentOS7, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Remove emoji contentNext article:Remove emoji content