Welcome! Log In Create A New Profile

Advanced

Re: Nginx memcached setting

November 22, 2010 06:02PM
On 11/21/10 12:29 PM, sastro wrote:
> 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
> [code]
> 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;
> }
>
> }
>
> [/code]
>
>
> 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;
> }
> }

Nowhere. Use the WordPress memcached plugin at
http://wordpress.org/extend/plugins/memcached/ 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 http://wiki.nginx.org/IfIsEvil.

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: http://forum.nginx.org/read.php?2,152247,152247#msg-152247


--
Jim Ohlstein

>> Why?
> Because it breaks the logical flow of conversation, plus makes
messages unreadable.
>>> Top-Posting is evil.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx memcached setting

sastro November 21, 2010 12:29PM

Re: Nginx memcached setting

sastro November 22, 2010 06:08AM

Re: Nginx memcached setting

Jim Ohlstein November 22, 2010 06:02PM

Re: Nginx memcached setting

sastro November 23, 2010 03:52PM

Re: Nginx memcached setting

sastro November 25, 2010 04:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 250
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready