cancel
Showing results for 
Search instead for 
Did you mean: 

Installing REDIS with Magento 1.8.1 not working?.

Highlighted

Installing REDIS with Magento 1.8.1 not working?.

Hello,

 

Installing REDIS with Magento 1.8.1 not working

I've been struggling with this one (of course!) for a while. Can't wrap my brain around it.

Magento just won't connect to the REDIS server. Since i'm getting not errors but a "there has been an error processing your request message" I was forced to put "Mage::setIsDeveloperMode(true);" in the index.php (in the magento root) to view the error.

This is the error i'm not getting:

Connection to Redis failed after 2 failures.

#0 /usr/share/nginx/html/lib/Credis/Client.php(412): Credis_Client->connect()
#1 /usr/share/nginx/html/lib/Credis/Client.php(674): Credis_Client->connect()
#2 /usr/share/nginx/html/lib/Credis/Client.php(573): Credis_Client->__call('select', Array)
#3 /usr/share/nginx/html/app/code/community/Cm/Cache/Backend/Redis.php(125): Credis_Client->select(0)
#4 /usr/share/nginx/html/lib/Zend/Cache.php(153): Cm_Cache_Backend_Redis->__construct(Array)
#5 /usr/share/nginx/html/ ometv omegle chatroulette lib/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true)
#6 /usr/share/nginx/html/app/code/core/Mage/Core/Model/Cache.php(137): Zend_Cache::factory('Varien_Cache_Co...', 'Cm_Cache_Backen...', Array, Array, true, true, true)
#7 /usr/share/nginx/html/app/code/core/Mage/Core/Model/Config.php(1348): Mage_Core_Model_Cache->__construct(Array)
#8 /usr/share/nginx/html/app/Mage.php(463): Mage_Core_Model_Config->getModelInstance('core/cache', Array)
#9 /usr/share/nginx/html/app/code/core/Mage/Core/Model/App.php(401): Mage::getModel('core/cache', Array)
#10 /usr/share/nginx/html/app/code/core/Mage/Core/Model/App.php(295): Mage_Core_Model_App->_initCache(Array)
#11 /usr/share/nginx/html/app/code/core/Mage/Core/Model/App.php(337): Mage_Core_Model_App->baseInit(Array)
#12 /usr/share/nginx/html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#13 /usr/share/nginx/html/index.php(88): Mage::run('', 'store')
#14 {main}

I'm using a copy of CentOS 6.5 running on VMplayer.

I've have everything setup with:

NGINX > PHP-FPM > MAGENTO 1.8.1 > MYSQL > REDIS

Here's the version of what's i'm running:

nginx-1.6.2-1.el6.ngx.x86_64
redis-2.8.19-1.el6.remi.x86_64
php-pecl-redis-2.2.5-1.el6.x86_64
mysql-server-5.1.73-3.el6_5.x86_64
php-mysql-5.3.3-40.el6_6.x86_64
php-fpm-5.3.3-40.el6_6.x86_64

My NGINX configuration:

user nginx nginx;worker_processes  2;pid               /var/run/nginx.pid;events {    worker_connections  1024;
}http {        include                 /etc/nginx/mime.types;        default_type            application/octet-stream;        include /etc/nginx/custom.d/http_level/*.conf;

        error_log              /var/log/nginx/error.log  error;

        log_format      custom  '{ "@timestamp": "$time_iso8601", "webserver_remote_addr": "$remote_addr", "webserver_remote_user": "$remote_user", "webserver_body_bytes_sent": $body_bytes_sent, "webserver_request_time": $request_time, "webserver_status": "$status", "webserver_request": "$request", "webserver_request_method": "$request_method", "webserver_http_referrer": "$http_referer", "webserver_http_user_agent": "$http_user_agent" }';


        access_log             /var/log/nginx/access.log custom;

        server_tokens           off;

        proxy_read_timeout      7200;
        fastcgi_read_timeout    7200;

        server_names_hash_bucket_size 128;

        sendfile                on;
        tcp_nopush              on;
        tcp_nodelay             on;
        keepalive_timeout       120;
        client_max_body_size    120m;

        gzip on;
        gzip_vary on;
        gzip_types text/javascript text/css application/xml application/x-javascript application/javascript;

        variables_hash_max_size 1024;
        variables_hash_bucket_size 128;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  # don’t use SSLv3 ref: POODLE



        upstream php53_mydomain_com_www_mydomain_com {
            server 127.0.0.1:9000;
        }


        # mydomain_com_www_mydomain_com
        map $http_host $magento_multistore_key_mydomain_com_www_mydomain_com {
                default default;
                www.mydomain.com en_us;

        }

        map $http_host $magento_multistore_type_mydomain_com_www_mydomain_com {
                default store;
                www.mydomain.com store;

        }

        server {
            listen              127.0.0.1:80;
            server_name         mydomain.com www.mydomain.com;
            root                /usr/share/nginx/html/;



        include /etc/nginx/custom.d/server_level/*.conf;



            location ~* ^/(server-status|whm-server-status) {
                stub_status on;
                access_log   off;
                allow 10.10.221.2;
                allow 10.10.221.3;
                allow 192.168.209.129;
                allow 10.10.17.108;
                allow 127.0.0.1;
                deny all;
            }

            location /php-fpm-status {
                access_log   off;
                allow 10.10.221.2;
                allow 10.10.221.3;
                allow 192.168.209.129;
                allow 127.0.0.1;

                fastcgi_pass php53_mydomain_com_www_mydomain_com;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
            }

            # Direct download
            location ~* ^/(js|static|skin|media|images)/ { expires 1w; }
            location /errors/ { }
            location ~* ^/errors/.*\.xml$ { deny all; }
            location ~* ^/errors/.*\.phtml$ { deny all; }

            # Deny
            location ~* /(\.ht|\.svn|\.git) { deny all; }
            location ~* ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { deny all; }

            # 503 error page
#           error_page 500 502 503 504 /503.html;
#           fastcgi_intercept_errors on;
#           location = /503.html { }

            autoindex off;

            location / {
                try_files $uri $uri/ /index.php?$args;
                index index.php index.html;
                access_log off;
            }

            location ~* \.(jpeg|jpg|gif|png|css|js|ico|swf)$ {
                try_files $uri $uri/ /get.php;
                expires 1w;
                access_log off;
            }

            location @proxy {
                try_files $uri =404; # if reference to php executable is invalid return 404
                expires off;
                fastcgi_pass php53_mydomain_com_www_mydomain_com;
                fastcgi_keep_conn on;
                fastcgi_buffer_size 128k;
                fastcgi_buffers 4 256k;


                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }

            location ~\.php$ {
                try_files $uri =404; # if reference to php executable is invalid return 404
                expires off;
                fastcgi_pass php53_mydomain_com_www_mydomain_com;
                fastcgi_keep_conn on;
                fastcgi_buffer_size 128k;
                fastcgi_buffers 4 256k;

                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param MAGE_RUN_CODE $magento_multistore_key_mydomain_com_www_mydomain_com;
                fastcgi_param MAGE_RUN_TYPE $magento_multistore_type_mydomain_com_www_mydomain_com;
            }
        }
}

My REDIS config has the usual bind 127.0.0.1 on port 6379 (i've verified that it's listening, and it is)

[root@www cache]# netstat -anp | grep -i 6379tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN      47642/redis-server  
unix  3      [ ]         STREAM     CONNECTED     26379  7905/Xorg           @/tmp/.X11-unix/X0

And finally my magento local.xml file:

<session_save><![CDATA[files]]></session_save>
<cache>
  <backend>Cm_Cache_Backend_Redis</backend>
  <backend_options>
    <server>127.0.0.1</server> <!-- or absolute path to unix socket -->
    <port>6379</port>
    <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 -->
    <database>0</database> <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
    <password></password> <!-- Specify if your Redis server requires authentication -->
    <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
    <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures; a value of 1 will not retry after the first failure -->
    <read_timeout>10</read_timeout>         <!-- Set read timeout duration; phpredis does not currently support setting read timeouts -->
    <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, lz4 (as l4z) and snappy -->
    <use_lua>0</use_lua> <!-- Set to 1 if Lua scripts should be used for some operations -->
  </backend_options>
</cache>

 

Thanks

alexsunny