最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

magento redis配置 redhat+nginx

Magento 资料整理 ajiang-tuzi 5311浏览

一:rehat nginx下安装redis

wget http://download.redis.io/releases/redis-2.8.4.tar.gz
tar xzvf redis-2.8.4.tar.gz -C /redis-2.8.7
cd /redis-2.8.7/redis-2.8.4
make PREFIX=/redis-2.8.7/redis-2.8.4 install
 
cd /redis-2.8.7/redis-2.8.4/bin
./redis-server --port  6379

二:测试服务器redis

./redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set name longmore
OK
127.0.0.1:6379> get name
"longmore"

三:安装phpredis组件

安装phpredis,到这里下载https://github.com/nicolasff/phpredis/,解压进入目录
#如果没有phpize 可以先安装 sudo apt-get install php5-dev

./configure –with-php-config=/alidata/server/php-5.2.17/bin/php-config
make && make install

然后修改 php.ini,


vim /etc/php.ini

#加入

extension=redis.so

然后重启服务器 nginx php-fpm

service php-fpm restart

/alidata/server/nginx/sbin/nginx -s reload

然后phpinfo 查看 php扩展,搜索redis

redis
因为我用的是Netbeans IDE,所以我添加了phpredis-phpdoc,下载https://github.com/ukko/phpredis-phpdoc 然后解压,在netbeans的项目->属性->PHP包含路径->添加
然后新建一个测试文件

$redis = new Redis(); $redis--->connect('127.0.0.1', 6379);
 
$redis->set('test', 'this is redis test');
 
echo $redis->get('test');

输出this is redis test,到此整个配置过程结束

四:magento 配置redis local.xml global标签里面添加

<session_save><![CDATA[files]]></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>3</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>
 
<cache>
<backend>Mage_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>4</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 -->
<compress_data>1</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 -->
<persistent>1</persistent> <!-- persistence value, 0: not in use, > 0 used as persistence ID -->
</backend_options>
</cache>
 
<full_page_cache>
<backend>Mage_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>5</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>

五:magento安装redis插件 magento1.8默认有只需要开启

/app/etc/modules/Cm_RedisSession.xml  false=>true

注: 启动redis 切换到当前目录 bin

./redis-server /usr/local/redis/etc/redis.conf 

备注及引用
本文的内容 整理自互联网 仅供学习 和交流所用

转载请注明:(●--●) Hello.My Weicot » magento redis配置 redhat+nginx

蜀ICP备15020253号-1