Config Problem for Wordpress 2.5

I am currently using Nginx to serve images only, but I have written a
script to launch the Nginx process, and php-cgi processes needed to run
Wordpress. I don’t seem to have the cofiguration correctly written, and
I’m not sure where I am making my error, so I could use some help. I
also don’t use the wp-cache, or Supercache plugins. I am running a
RedHat 5 Enterprise Server. Here is my configuration:

server {
    listen       my_ip_address:80;
    server_name  www.mydomain.com mydomain.com;
    error_page  404              http://www.mydomain.com/e404.php;

location / {
root /var/www/mydomain;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?q=$1 last;
}

     valid_referers none blocked images.google.com;
        if ($invalid_referer) {
        # return   404;
                    rewrite  ^(.*)$  http://www.mydomain.com/;
                    }
    deny blocked_ip_address;
    allow all;

   }

location ~ .php$ {
   fastcgi_pass  localhost:9999;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_NAME $fastcgi_script_name;
   fastcgi_param REQUEST_URI $request_uri;
   fastcgi_param DOCUMENT_URI $document_uri;
   fastcgi_param DOCUMENT_ROOT $document_root;
   fastcgi_param REMOTE_ADDR $remote_addr;
   fastcgi_param REMOTE_PORT $remote_port;
   fastcgi_param SERVER_ADDR $server_addr;
   fastcgi_param SERVER_PORT $server_port;
   fastcgi_param SERVER_NAME $server_name;
   fastcgi_param SCRIPT_FILENAME

/var/www/mydomain$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
}

    }

Alle sabato 12 aprile 2008, Todd HG ha scritto:

I am currently using Nginx to serve images only, but I have written a
script to launch the Nginx process, and php-cgi processes needed to run
Wordpress. I don’t seem to have the cofiguration correctly written, and
I’m not sure where I am making my error, so I could use some help. I
also don’t use the wp-cache, or Supercache plugins. I am running a
RedHat 5 Enterprise Server. Here is my configuration:

Ok, but what is the problem/error that you’re seeing?

Chuck

location ~ .php$ {

this stuff in an include file for easier maintenance:

   fastcgi_param SERVER_NAME $server_name;
   fastcgi_param SCRIPT_FILENAME

/var/www/mydomain$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

}

And be sure to notice that you just opened up a HUGE hole in that ANY
.php file on the filesystem is now executable. This means if you have
an upload dir then if someone can upload a file with a .php extension to
it then they can point their browser to it and trigger the rule above to
execute that file… ugg

Limit the regexp to only trigger on dirs that you expect php scripts to
be in - OR - setup a location for the upload dir with a break in it to
take precedence over the .php rule.

The stuff above looks basically ok - you need to post your error
messages to get more help

Ed W

I am getting a 404 error.

Actually

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

is better too, then you can put it in an include. Otherwise, each
virtual host’s path needs to be hardcoded (and it doesn’t need to be!)

Just make sure the “root” of your vhost has the ending slash/; - I
stumbled across that one.

Also fastcgi_pass might be different per vhost (different fastcgi
pools, based on user ID for example) - basically, put everything
that’s the same in an include, and keep only the specific stuff
outside of it. I agree with Ed but wanted to point out a couple
exceptions :slight_smile:

Kiril A. wrote:

You need some rewrite rules.

if (!-e $request_filename) {
rewrite ^.+/?(/wp-.) $1 last;
rewrite ^.+/?(/.
.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}

Kiril

Still getting the same 404 error with those rewrite rules. I am not
using wp-cache or supercache.

You need some rewrite rules.

if (!-e $request_filename) {
rewrite ^.+/?(/wp-.) $1 last;
rewrite ^.+/?(/.
.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}

Kiril

have you tried this?
http://www.romej.com/archives/515/nginx-rewrite-rules-for-wordpress-redux

other ideas/links:
http://aleksandarsavic.com/nginx-and-wordpress-setup-clean-seo-friendly-urls/
http://elasticdog.com/2008/02/howto-install-wordpress-on-nginx/

Typically WP installs have basically “if file does not exist, go
through /wordpress/index.php” or wherever your wordpress physical
directory resides.

    if (!-e $request_filename) {
        rewrite ^(.+)$ /index.php?q=$1 last;
    }

If that stuff doesn’t work, please post your config (edit out the
hostnames if you wish) you might have conflicting rules or something.

I’m getting black pages when trying to get to the web site, but I can
navigate around the Wordpress control panel just fine. I can’t see my
error. Here’s my entire config:

user nobody;
worker_processes 2;

pid /usr/local/nginx/logs/nginx.pid;

events {
worker_connections 12000;
use epoll;
}

http {
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;

expires       1M;
add_header    Cache-Control  must-revalidate;
add_header    Cache-Control  public;
server_tokens off;

client_header_timeout  3m;
client_body_timeout    3m;
send_timeout           3m;

gzip on;
gzip_min_length  1100;
gzip_buffers     4 8k;
gzip_http_version 1.1;
gzip_proxied any;
gzip_types   text/css application/x-javascript;
gzip_comp_level 5;

sendfile       on;
tcp_nopush     on;
tcp_nodelay    on;
keepalive_timeout  5 5;

server_names_hash_bucket_size 128;

server {
    listen       my-ip-address:80;
    server_name  www.mydomain.com mydomain.com;

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

    if (-f $request_filename) {
        expires 30d;
        break;
    }

    if (!-e $request_filename) {
        rewrite ^(.+)$ /index.php?q=$1 last;
     }
    error_page  404              http://www.mydomain.com/e404.php;
}

location ~ .php$ {
fastcgi_pass 127.0.0.1:9999;
fastcgi_index index.php;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME
/var/www/mydomain$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param REDIRECT_STATUS 200;

 }

valid_referers none blocked mydomain.com www.mydomain.com
images.google.com;
if ($invalid_referer) {
# return 404;
rewrite ^(.*)$ http://www.mydomain.com/;
}
deny blocked-ip;
allow all;

   }

}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs