Environment: Centos7 PHP7
1. Cut to the directory you want to install
Cd/usr/local
2. Download Redis
wget http://download.redis.io/redis-stable.tar.gz
3. Unzip
TAR-ZXF redis-stable.tar.gz
4. Compiling
Make
5. Line 5th after 1000 change to after 10000
VI TESTS/INTEGRATION/REPLICATION-PSYNC.TCL
6. Enter the SRC directory
CD src
7. Compile Check
Make Test
8. Installation
Make install
9. Rename the catalog by cutting to the outer layer
Cd/usr/local
MV Redis-stable Redis
10. Modify the configuration
VI redis/redis.conf
Search Daemonize Change to daemonize Yes
Search Pidfile to Pidfile/usr/local/redis/redis.pid
Search logfile to Logfile/usr/local/redis/redis.log
Search Save 60 10000 instead of Save 60 1000
Search #maxmemory <bytes> change to MaxMemory 256M
One . start Redis
/usr/local/redis/src/redis-server
Boot Start
Vi/etc/init.d/redis
Enter the following path to the actual path:
#!/bin/bash
# chkconfig:2345 10 90
# Description:start and Stop Redis
Path=/usr/local/bin:/sbin:/usr/bin:/bin
redisport=6379
Exec=/usr/local/redis/src/redis-server
Redis_cli=/usr/local/redis/src/redis-cli
Pidfile=/usr/local/redis/redis.pid
conf= "/usr/local/redis/redis.conf"
Auth= "1234"
Case "$" in
start)
if [-F $PIDFILE]
Then
echo "$PIDFILE exists, process is already running or crashed."
Else
echo "Starting Redis server ..."
$EXEC $CONF
fi
if ["$?" = "0"]
Then
echo "Redis is running ..."
fi
;;
stop)
if [!-F $PIDFILE]
Then
echo "$PIDFILE exists, process is not running."
Else
pid=$ (cat $PIDFILE)
echo "Stopping ..."
$REDIS _cli-p $REDISPORT SHUTDOWN
Sleep 2
While [-X $PIDFILE]
Do
echo "Waiting for Redis to shutdown ..."
Sleep 1
Done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} Stop
${0} start
;;
*)
echo "Usage:/etc/init.d/redis {start|stop|restart|force-reload}" >&2
Exit 1
Esac
Save exit: Wq
13. Turn on the service
/etc/init.d/redis start
Successful if you see the following information
Starting Redis Server ...
Redis is running ...
14. Start the client:
/usr/local/redis/src/redis-cli
Use the Set get
Store data OK
15. Set Boot
Chkconfig Redis on
Installing the Redis Extension
16.:
Https://github.com/phpredis/phpredis/archive/php7.zip
Uploading to Linux with FTP
Please check your PHP version to find the right extension.
17. Move to the ready-to-install directory
MV Phpredis-php7.zip/usr/local/phpredis-php7.zip
18. Unzip
Unzip Phpredis-php7.zip
19. Enter the directory
CD PHPREDIS-PHP7
20. Execute phpize under the PHP installation directory
/usr/local/php7/bin/phpize
21. Error message:
Cannot find autoconf. Please check your autoconf installation and the
$PHP _autoconf environment variable. Then, rerun the this script.
Workaround:
Yum Install M4
Yum Install autoconf
Execute phpize again:
/usr/local/php7/bin/phpize
22. Search Php-config Path
find/usr/local/php7/-name Php-config
Get/usr/local/php7/bin/php-config
23. Configuration
./configure--with-php-config=/usr/local/php7/bin/php-config
24. Compiling
Make
25. Installation
Make install
The following results appear:
26. Edit PHP.ini
Vi/usr/local/php7/etc/php.ini
Join in a row of extension:
Extension=redis.so
Restart Apache
Systemctl Restart httpd
new php file Run phpinfo ()
Search for Redis extensions
Run the following code if the access is normal, the installation succeeds .
$redis = new Redis ();
$redis->connect (' 127.0.0.1 ', 6379);
$redis->set ("name", "Hello World");
echo $redis->get ("name");
Thanks for reading
Installation configuration for Redis under Linux