Nginx memcached setting

My server running Nginx and php-fpm for wordpress. Today i installed
memcached but i dont know how to setting the memcached thing into conf
file. Here is my wordpres conf file

server{
        listen 80;
        server_name www.mywebsite.com;
        access_log /var/log/nginx/mywpt.access_log;
        error_log /var/log/nginx/mywpt.error_log;

    root /home/mywebsite/public_html;

        location / {
          root /home/mywebsite/public_html/;
          index index.html index.htm index.php;

          # this serves static files that exist without running other
rewrite tests
          if (-f $request_filename) {
              expires 30d;
              break;
          }

          # this sends all non-existing file or directory requests to
index.php
          if (!-e $request_filename) {
              rewrite ^(.+)$ /index.php?q=$1 last;
          }
        }

        location ~ \.php$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME
/home/mywebsite/public_html/$fastcgi_script_name;
            include         fastcgi_params;
        }

}

where to put this code ?

server {
location / {
set $memcached_key $uri;
memcached_pass name:11211;
default_type text/html;
error_page 404 @fallback;
}

location @fallback {
proxy_pass backend;
}
}

Posted at Nginx Forum:

Please someone help me

Posted at Nginx Forum:

On 11/21/10 12:29 PM, sastro wrote:

root /home/mywebsite/public_html;
       }
         fastcgi_index   index.php;

where to put this code ?
proxy_pass backend;
}
}

Nowhere. Use the WordPress memcached plugin at
Memcached Object Cache – WordPress plugin | WordPress.org and it will do the work
for you. Do make certain that you have memcached installed (and running)
as well as the PECL-memcache PHP extension. See http://memcached.org/
and http://pecl.php.net/package/memcache.

BTW, if you really want efficiency for your site, and since you’re
asking about using memcached it seems that you are, you should rewrite
the config to get rid of the if’s, and use locations and try_files
instead. See If is Evil… when used in location context | NGINX.

A more efficient config might be (not tested so YMMV):

server{
listen 80;
server_name www.mywebsite.com;
access_log /var/log/nginx/mywpt.access_log;
error_log /var/log/nginx/mywpt.error_log;

root /home/mywebsite/public_html;

#will capture most static files and serve them. Add other types if you
need to

     location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {
 expires 30d;

}

     location / {
       root /home/mywebsite/public_html/;
       index index.html index.htm index.php;

       # this will capture and serve any other static file types

missed above and send the rest to your fallback rewrite
try_files $uri $uri/ /index.php?q=$request_uri;
}

     location ~ \.php$ {
         fastcgi_pass    127.0.0.1:9000;
         fastcgi_index   index.php;
         fastcgi_param   SCRIPT_FILENAME

/home/mywebsite/public_html/$fastcgi_script_name;
include fastcgi_params;
}

}

Posted at Nginx Forum:
Nginx memcached setting


Jim O.

Why?
Because it breaks the logical flow of conversation, plus makes
messages unreadable.

Top-Posting is evil.

Please help me

Posted at Nginx Forum:

Thanks for replied.
I’m not using memcached with php but stand alone. I want to using nginx
and memcached + php-fpm and eaccelerator.
i did tried this for my low traffic website and it works

server{
        listen 80;
        server_name www.lowtraffic.net;
        access_log /var/log/nginx/lowtraffic.net.access_log;
        error_log /var/log/nginx/lowtraffic.net.error_log;

    root /home/lowtraffic/public_html/;

  location / {
    set $memcached_key $uri;
    memcached_pass     127.0.0.1:11211;
    default_type       text/html;
    error_page         404 405 = @fallback;
  }

  location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {
      expires 30d;
      access_log off;
    }
        location ~ \.php$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME
/home/lowtraffic/public_html/$fastcgi_script_name;
            include         fastcgi_params;
        }
    location @fallback {
    rewrite ^ /index.php?q=$uri last;
     }
}

But when i using with >1000 visitors online on the same time, i got
request time out.
What’s wrong?

Posted at Nginx Forum: