First release path: installation of Phpredis
Very long time did not write blog, a lot of blog has not finished finishing, today just take time to finish this blog post, I hope to have a certain help to everyone
Let's start with a brief introduction to Redis:
Redis is completely open source free, complies with BSD protocol, advanced Key–value persistent products.
It is commonly referred to as the data structure server, because the values (value) can be strings (string), hashes (MAP), lists (list), collections (sets), and ordered collections (sorted sets) and other types.
This is the Chinese translation of the official website. English is not necessary to write up, false vision to see English, can go to redis.io up to see, Chinese can go to redis.cn see
There have been a lot of people writing about the installation and use of Php-redis. I'm just over here. A verification process
Installing Redis
wget http://download.redis.io/redis-stable.tar.gz
Tar xvzf redis-stable.tar.gz
CD redis-stable
Make
sudo make install (assuming the root user can not use sudo)
After the installation is complete, copy the following configuration file redis.conf. This is for more convenient use.
sudo mkdir/etc/redis/
sudo cp redis.conf/etc/redis/
At this point start the next redis look at the boot method:
Redis-server/etc/redis/redis.conf
The interface effect after startup:
[Email protected]:~/documents/phpredis$ redis-server/etc/redis/redis.conf
[16859] 10:05:30.292 # requested maxclients of 10000 requiring at least 10032 max file descriptors.
[16859] 10:05:30.293 # Redis can ' t set maximum open files to 10032 because of OS error:operation not permitted.
[16859] 10:05:30.293 # Current maximum open files are 1024. MaxClients have been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase ' ulimit-n '.
[16859] 10:05:30.293 # warning:32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with ' noeviction ' policy now.
_._
_.-“__ ”-._
_.-"'. `_. "-._ Redis 2.8.13 (00000000/0)
.-".-" '. "' \ \ _.,_"-._
(',.-' | ',) Running in Stand alone mode
| '-._ '-...-' __...-. ' -._| ' ' _.-' | port:6379
| '-._ '. _/_.-' | pid:16859
'-._ '-._ '-./_.-' _.-'
| '-._ '-._ '-.__.-' _.-' _.-' |
| '-._ '-._ _.-' _.-' | Http://redis.io
'-._ '-._ '-.__.-' _.-' _.-'
| '-._ '-._ '-.__.-' _.-' _.-' |
| '-._ '-._ _.-' _.-' |
'-._ '-._ '-.__.-' _.-' _.-'
'-._ '-.__.-' _.-'
'-._ _.-'
'-.__.-'
[16859] 10:05:30.308 # Server started, Redis version 2.8.13
[16859] 10:05:30.308 # WARNING Overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ' Vm.overcommit_memory = 1′to/etc/sysctl.conf and then reboot or run the command ' Sysctl vm.overcom Mit_memory=1′for this to take effect.
[16859] 10:05:30.308 * The server is now-accept connections on port 6379
Suppose you want to perform in the background, be able to execute redis-server/etc/redis/redis.conf &, or change the daemonize settings in the configuration file/etc/redis/redis.conf to Yes.
After set to Daemonize. Start Redis-server. and use REDIS-CLI to connect the Redis-server
Redis-cli
After the connection is successful:
[Email protected]:~/documents/phpredis$ redis-cli
127.0.0.1:6379>
Enter info to view:
127.0.0.1:6379> Info
# Server
redis_version:2.8.13
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7331093c2c819968
Redis_mode:standalone
Os:linux 3.2.0-29-generic-pae i686
Arch_bits:32
Multiplexing_api:epoll
gcc_version:4.6.3
process_id:16890
run_id:660fc790eb501ea29b01b8bb9551f4711ab5f151
tcp_port:6379
Uptime_in_seconds:6
uptime_in_days:0
Hz:10
lru_clock:14868319
Config_file:/etc/redis/redis.conf
# clients
Connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:424880
used_memory_human:414.92k
used_memory_rss:1609728
used_memory_peak:424880
used_memory_peak_human:414.92k
used_memory_lua:22528
mem_fragmentation_ratio:3.79
mem_allocator:jemalloc-3.6.0
# persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1407377241
Rdb_last_bgsave_status:ok
Rdb_last_bgsave_time_sec:-1
Rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
Aof_last_rewrite_time_sec:-1
Aof_current_rewrite_time_sec:-1
Aof_last_bgrewrite_status:ok
Aof_last_write_status:ok
# Stats
Total_connections_received:1
total_commands_processed:0
instantaneous_ops_per_sec:0
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
# Replication
Role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:0.00
used_cpu_user:0.00
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Keyspace
This indicates that the Redis service started successfully. As for optimization. The following article is to say
Next we go to configure Php-redis
The first thing to install is Git,php5,apache2,php5-dev
sudo apt-get install php5 php5-dev apache2
Installation Required Point time
Under the Php-redis source folder. Run
git clone Https://github.com/nicolasff/phpredis.git
Phpize
./configure
Make && sudo make install
Tip Information:
Installing Shared extensions:/usr/lib/php5/20121212+lfs/
Shared library under the path indicated above
Configure Php-redis
Create index.php under/var/www/html, which includes the following:
<?php
Phpinfo ();
?
>
and create a Redis.ini under/etc/php5/mods-available, such as the following:
Extension=redis.so
And in/ETC/PHP5/APACHE2/CONF.D and/ETC/PHP5/CLI/CONF.D to establish a soft link with redis.ini, the CLI this part is very critical, otherwise php-m can not get Redis no matter what module information, That cannot be loaded successfully using Phpredis
Ln-s/etc/php5/mods-available/redis.ini/etc/php5/cli/conf.d/10-redis.ini
Ln-s/etc/php5/mods-available/redis.ini/etc/php5/apache2/conf.d/10-redis.ini
Restarting the APACHE2 service
sudo service apache2 restart
Here to open Ubuntu corresponding ip/index.php will be able to see the configuration of Php-redis
Additional. ini files parsed |
/etc/php5/apache2/conf.d/05-opcache.ini,/etc/php5/apache2/conf.d/10-pdo.ini,/etc/php5/apache2/conf.d/10- Redis.ini,/etc/php5/apache2/conf.d/20-json.ini,/etc/php5/apache2/conf.d/20-readline.ini |
Redis
Redis | Support
enabled |
Redis Version |
2.2.5 |
Session
session support |
Enabled |
Registered Save handlers |
files user Redis |
registered Serializer Handlers |
php_serialize PHP php_binary wddx |
With this information, start the test code.
Establish testredis.php. The contents are as follows:
<?php
$redis = new Redis ();
$redis->connect (' 127.0.0.1′,6379);
Var_dump ($redis->info ());
?>
Then run PHP testredis.php
Ability to see the content in the terminal
It is also possible to see the corresponding content on the Web side.
So even if the Php-redis is basically built.
[Redis Album] [Methods and steps for installing Php-redis under 1]ubuntu12.04