配置magento redis环境

1,安装redis

centos下(64位):

1
2
3
4
5
6
7
8
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6*.rpm
rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
su
yum install redis php-pecl-redis
chkconfig redis on
service redis start
service httpd restart

 

ubuntu下:

1
2
3
4
5
6
sudo -i
apt-get install redis-server php5-dev php5-cli php-pear
pecl install redis
echo "extension=redis.so" > /etc/php5/mods-available/redis.ini
php5enmod redis
service apache2 restart

2,测试redis服务器是否正常

1
2
redis-cli ping
php -m | grep redis

3,配置magento

vim app/etc/local.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0"?>
<!--
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Core
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
<config>
<global>
...
<!-- <session_save><![CDATA[files]]></session_save> -->
<!-- <session_save><![CDATA[memcached]]></session_save>
        <session_save_path><![CDATA[tcp://127.0.0.1:11211?persistent=0&weight=2&timeout=10&retry_interval=10]]></session_save_path>
        <session_cache_limiter><![CDATA[]]></session_cache_limiter> -->
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server>
<port>6379</port>
<persistent></persistent>
<database>0</database>
<password></password>
<force_standalone>0</force_standalone>
<connect_retries>2</connect_retries>
<read_timeout>10</read_timeout>
<automatic_cleaning_factor>0</automatic_cleaning_factor>
<compress_data>1</compress_data>
<compress_tags>1</compress_tags>
<compress_threshold>20480</compress_threshold>
<compression_lib>gzip</compression_lib>
</backend_options>
<lifetime>1296000</lifetime>
</cache>
<full_page_cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server>
<!-- or absolute path to unix socket for better performance -->
<port>6379</port>
<database>1</database>
<password></password>
<force_standalone>0</force_standalone>
<!-- 0 for phpredis, 1 for standalone PHP -->
<connect_retries>1</connect_retries>
<!-- Reduces errors due to random connection failures -->
<automatic_cleaning_factor>0</automatic_cleaning_factor>
<!-- Disabled by default -->
<!-- in FPC data is already gzipped, no need to do this twice -->
<compress_data>0</compress_data>
<!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_tags>1</compress_tags>
<!-- 0-9 for compression level, recommended: 0 or 1 -->
<compress_threshold>20480</compress_threshold>
<!-- Strings below this size will not be compressed -->
<compression_lib>gzip</compression_lib>
<!-- Supports gzip, lzf and snappy -->
<lifetimelimit>43200</lifetimelimit>
<!-- set lifetime for keys without TTL -->
<persistent>2</persistent>
</backend_options>
</full_page_cache>

<session_save>db</session_save>
<redis_session>
<!-- All options seen here are the defaults -->
<host>127.0.0.1</host>
<!-- Specify an absolute path if using a unix socket -->
<port>6379</port>
<password></password>
<!-- Specify if your Redis server requires authentication -->
<timeout>2.5</timeout>
<!-- This is the Redis connection timeout, not the locking timeout -->
<persistent></persistent>
<!-- Specify unique string to enable persistent connections. E.g.: sess-db0;
bugs with phpredis and php-fpm are known:
https://github.com/nicolasff/phpredis/issues/70 -->
<db>0</db>
<!-- Redis database number; protection from accidental loss is improved by
using a unique DB number for sessions -->
<compression_threshold>2048</compression_threshold>
<!-- Set to 0 to disable compression (recommended when
suhosin.session.encrypt=on); known bug with strings over 64k:
https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/18 -->
<compression_lib>gzip</compression_lib>
<!-- gzip, lzf or snappy -->
<log_level>1</log_level>
<!-- 0 (emergency: system is unusable), 4 (warning; additional information,
recommended), 5 (notice: normal but significant condition), 6 (info: informational
messages), 7 (debug: the most information for development/testing) -->
<max_concurrency>6</max_concurrency>
<!-- maximum number of processes that can wait for a lock on one session; for
large production clusters, set this to at least 10% of the number of PHP processes
-->
<break_after_frontend>5</break_after_frontend>
<!-- seconds to wait for a session lock in the frontend; not as critical as
admin -->
<break_after_adminhtml>30</break_after_adminhtml>
<bot_lifetime>7200</bot_lifetime>
<!-- Bots get shorter session lifetimes. 0 to disable -->
</redis_session>
</global>
<admin>
<routers>
<adminhtml>
<args>
<frontName><![CDATA[admin]]></frontName>
</args>
</adminhtml>
</routers>
</admin>
</config>

 

坚持原创技术分享,您的支持将鼓励我继续创作!