Previous: Build Lnamp Environment (iv)-source installation PHP7
I. Installation of Redis
1. Create Redis user groups and users
Groupadd Redisuseradd-r-G redis-s/sbin/nologin-m Redis
2. Download the Redis source package and put the source package into the/usr/local/src/directory
Download page: Http://redis.io/download
Redis-3.2.5.tar.gz is used here.
: http://download.redis.io/releases/redis-3.2.5.tar.gz
3. Enter the src/directory
cd/usr/local/src/
4. Unzip the source package
TAR-ZXF redis-3.2.5.tar.gz
5. Enter the Redis source directory, compile and install
CD Redis-3.2.5/make Prefix=/usr/local/redis Install
6. Create a Redis file directory
Mkdir-p/usr/local/redis/datamkdir-p/usr/local/redis/etcmkdir-p/var/run/redismkdir-p/var/log/redis
7. Put the configuration file into the redis/etc/directory
CP redis.conf/usr/local/redis/etc/
8. Modify the Redis configuration file redis.conf
Vim/usr/local/redis/etc/redis.conf
9. Change to the following, save exit
Tcp-backlog #tcp队列长度, the CentOS system defaults to 128, this value should not be greater than the operating system daemonize Yes #改为yes, to ensure that Redis can run in the background pidfile/var/run/ Redis/redis.pid #redis pidlogfile "/var/log/redis/redis.log" #redis日志dir/usr/local/redis/data/ # Redis Data Storage Directory
#------Optional configuration------#slaveof 192.168.1.66 6379 #主从复制, CONFIGURED on sub-machine, example: IP 192.168.1.66, Port 6379#save 10000 #快照, example: 60s in 1000 0 changes Save #appendonly Yes #AOF持久化
10. Modify Redis Directory Permissions
Chown-r redis:redis/usr/local/redischown-r redis:redis/var/run/redischown-r Redis:redis/var/log/redis
11. Add the Redis command to the environment variable and modify the profile file
Vim/etc/profile
12. Change to the following, save exit
Path=/usr/local/mysql/bin:/usr/local/php/bin:/usr/local/redis/bin: $PATH
13. Make the configuration in/etc/profile effective immediately
Source/etc/profile
14. Add the Redis service script to the init.d/directory to create the REDISD file
Vim/etc/init.d/redisd
15. Add the following to save the exit
View Code
16. Add executable permissions for REDISD
chmod +X/ETC/INIT.D/REDISD
17. Joining Redis to system services
Chkconfig--add REDISD
18. Modify the default boot level for the service
Chkconfig REDISD on
19. Start Redis
Service REDISD Start
Second, PHP7 installation Redis expansion
1.yum Installing Git
Yum-y Install git
2. Enter the src/directory
cd/usr/local/src/
3.git Download Phpredis Expansion
git clone https://github.com/phpredis/phpredis.git
4. Enter the phpredis/directory
CD phpredis/
5. Default clone of php5 Redis extension, need to switch to PHP7 branch
git checkout PHP7
6. Build and install extensions
Phpize./configure--with-php-config=/usr/local/php/bin/php-configmake && make install
7. Modify the php.ini file
Vim/usr/local/php/etc/php.ini
8. Add redis.so extension configuration, save exit
Extension=redis.so
9. Restart Apache or PHP-FPM
Service httpd Restartservice php-fpm restart
10. Add php files to the web directory, such as/usr/local/apache/htdocs/redis.php or/usr/local/nginx/html/redis.php
<?php$redis = new Redis (), $redis->connect (' 127.0.0.1 ', 6379), $redis->set (' class ', ' TOEFL ');p Rint_r ($redis- >get (' class '));
Access URLs, such as: http://192.168.8.9/redis.php
The page is displayed correctly, the configuration is successful
Redis installation is complete!
Next: Build Lnamp Environment (vi)-PHP7 source installation MongoDB and MongoDB expansion
Building Lnamp Environment (v)-PHP7 source installation Redis and Redis expansion