Welcome! Log In Create A New Profile

Advanced

wordpress и nginx

Posted by dycode 
wordpress и nginx
June 14, 2011 12:42PM
Здравствуйте.
Уже вторые сутки пытаюсь подружить nginx с wordpress, все мануалы перечитал, ничего не помогает.

Версия nginx - 1.0.4
Версия php-cgi - 5.3.3
ОС - debian 5 и debian 6

Пробую как казано в мануале (wiki.nginx.org/Wordpress )
Если делать:
location /wordpress {
try_files $uri $uri/ /wordpress/index.php;
}

то не видны картинки, ссылки вида wp-admin, wp-content не открываються.

Если добавить:
location ~ \.php$ {
fastcgi_split_path_info ^(/wordpress)(/.*)$;
}
То вообще : No input file specified.


Если вписать:
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
тоже : No input file specified.


мой конфиг:

location / {
root /var/www;
index index.html index.htm index.php;
}
location /wordpress {
try_files $uri $uri/ /wordpress/index.php;
}
location ~ \.php$ {
fastcgi_split_path_info ^(/wordpress)(/.*)$;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}



Edited 1 time(s). Last edit at 06/14/2011 12:43PM by dycode.
FIXED
June 14, 2011 03:08PM
FIXED!
I add after "server {" line with root path - root /var/www;
and all works fine.

This is final works config:

server {
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /var/www/;

location / {
root /var/www;
index index.html index.htm index.php;
}

location /wordpress {
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}

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

}
Re: wordpress и nginx
June 19, 2011 06:43AM
дружить с ним надо правильно -) :

proxy_cache_path /var/lib/nginx/tmp/proxy levels=1:2 keys_zone=ws:100m max_size=1024m inactive=5 d;
proxy_cache_path /var/lib/nginx/tmp/proxy levels=1:2 keys_zone=media:100m max_size=1024m inactive=5d;
proxy_temp_path /var/lib/nginx/tmp/proxy_tmp 1 2;

proxy_buffering on;
proxy_cache_min_uses 1;
proxy_cache_valid 200 10m;
proxy_cache_valid 302 304 10m;
proxy_cache_valid 404 502 1m;
proxy_cache_valid 503 4s;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504;

proxy_pass_header Cookie;
proxy_pass_header Set-Cookie;

sendfile on;
tcp_nopush on;
tcp_nodelay on;

##keepalive_timeout 0;
keepalive_timeout 65;

gzip on;
gzip_min_length 1024;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml application/x-pointplus application/x-javascript text/css;
gzip_comp_level 3;

#
server {
listen x.x.x.x:80;
server_name ws.com;
server_name_in_redirect off;

set $media_ 0;

# set headers for the backend
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Host $http_host;
proxy_set_header X-URI $uri;
proxy_set_header X-ARGS $args;
proxy_set_header Refer $http_refer;

# pass headers from backend to client
proxy_pass_header Cookie;
proxy_pass_header Set-Cookie;

client_max_body_size 40m;
client_body_buffer_size 256k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_buffer_size 8k;
proxy_buffers 8 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 10m;

# capture cookies for use in the cache key
set $wordpress_logged_in "";
set $comment_author_email "";
set $comment_author "";
if ($http_cookie ~* "wordpress_logged_in_[^=]*=([^%]+)%7C") {
set $wordpress_logged_in wordpress_logged_in_$1;
}
if ($http_cookie ~* "comment_author_email_[^=]*=([^;]+)(;|$)") {
set $comment_author_email comment_author_email_$1;
}
if ($http_cookie ~* "comment_author_[^=]*=([^;]+)(;|$)") {
set $comment_author comment_author_$1;
}

# set the proxy cache key
set $my_cache_key $scheme$request_method$host$uri$is_args$args$wordpress_logged_in$comment_author_email$comment_author;


###Static files location
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|html|flv)$ {
root /srv/Web/www.ws.com/;

proxy_pass http://127.0.0.1:80;
proxy_redirect off;
proxy_cache media;
proxy_cache_key $my_cache_key;

proxy_cache_valid 200 302 304 30d;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504 http_404;

set $media_ 1;

expires 14d;
}

location /wp-admin {
proxy_pass http://127.0.0.1:80;
proxy_redirect off;
}

location /wp-login.php {
proxy_pass http://127.0.0.1:80;
proxy_redirect off;
}


location / {
proxy_pass http://127.0.0.1/;
proxy_redirect off;

proxy_cache ws;

proxy_cache_key $my_cache_key;
proxy_hide_header "Set-Cookie";
proxy_ignore_headers "Cache-Control" "Expires" "Set-Cookie";

access_log /srv/Web/www.ws.com/_NG_local.log;

set $media_ 0;
}

}
#end server
Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 228
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready