- Joined
- May 20, 2016
- Messages
- 149
- Points
- 28
Redis is an in-memory cache like memcached, which is stored in RAM for faster access than other types of cache on your hard disk, but Redis supports caching better than memcached, it supports many types of structures as String. hashes, lists, sets, etc and it is a perfect replacement for Memcached to use for blogs and websites.
Preparations before installing
Updatethe library:
Set compiler (if not already)
Set tcl
Install Redis
Download the latest Redis
Unzip to a folder and move the unzipped
Run this command to install :
Once installed Redis, we get a script file that allows Redis background. To use this script, moved to a folder utils
Run Ubuntu/Debian install script:
When this script has run, it will run Redis-server platform. Can use the following command to start/stop:
(Number 6379 depends on the port you use, the default is 6379)
If commands above have not set yet then run this command:
Install phpredis
Download source
If using PHP7 then at this time there is a package:
Unzip the downloaded file, move to the newly unzipped folder and run the following command to install:
If file extension didn't install right folder, copy the file redis.so in modules folder into PHP extensions directory. Then add the following to your php.ini file:
Use phpredis
For example, connect to Redis server:
For example, using phpredis simply:
Documents using Redis and phpredis at GitHub
If you have any other ways to install Redis and phpredis on Ubuntu, please write down. I look forward to reading all your comments.
Preparations before installing
Updatethe library:
Code:
sudo apt-get update
Code:
sudo apt-get install build-essential
Code:
sudo apt-get install tcl8.5
Download the latest Redis
Code:
wget http://download.redis.io/releases/redis-stable.tar.gz
Code:
tar xzf redis-stable.tar.gz
cd redis-stable
Code:
sudo make install
Code:
cd utils
Code:
sudo ./install_server.sh
Code:
sudo service redis_6379 start
sudo service redis_6379 stop
If commands above have not set yet then run this command:
Code:
sudo update-rc.d redis_6379 defaults
Download source
Code:
wget https://github.com/phpredis/phpredis/archive/develop.zip
Code:
wget https://github.com/phpredis/phpredis/archive/php7.zip
Code:
sudo phpize
sudo ./configure
sudo make
sudo make install
Code:
extension = redis.so
For example, connect to Redis server:
Code:
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
try {
$redis->ping();
} catch(RedisException $e) {
echo 'Error: ' . $e->getMessage();
exit;
}
echo 'Server is running';
Code:
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
try {
$redis->ping();
} catch(RedisException $e) {
echo 'Error: ' . $e->getMessage();
exit;
}
$redis->set('name', 'Maria');
echo $redis->get('name');
Code:
http://redis.io/documentation
https://github.com/phpredis/phpredis