Newbie config not working

hey all, nginx from freebsd ports 0.7.64 i386

Below is my config.

I am trying to move from a lighttpd server and try out nginx. Below is
my actual config. Everything is installed from ports. and php is being
run by spawn-fcgi

nginx.conf:

 1  worker_processes  2;
 2
 3  events {
 4      worker_connections  1024;
 5      use kqueue;
 6  }
 7
 8  http {
 9      include       mime.types;
10      default_type  application/octet-stream;
11      sendfile        on;
12      keepalive_timeout  65;
13
14      access_log  /var/log/nginx-access.log;
15      error_log   /var/log/nginx-error.log;
16
17      tcp_nopush  on;
18      tcp_nodelay  on;
19      charset  utf-8;
20      gzip   on;
21      gzip_types  text/plain application/xml text/javascript;
22      gzip_min_length  512;
23
24  server {
25    listen    80;
26    server_name  _;
27    server_name_in_redirect off;
28    access_log /var/log/nginx-default.log;
29
30    location / {
31    index index.html;
32    root  /usr/local/www/nginx;
33    }
34
35      }
36
37
38  server {
39          listen         80;
40          server_name    domain.org www.domain.org;
41          root       /usr/local/www/wordpress;
42    include   php_fastcgi_support;
43          index      index.php;
44
45          location / {
46      try_files $uri $uri/ /index.php?q=$uri&$args;
47          }
48
49      }
50
51  server {
52    listen    443;
53    ssl    on;
54    ssl_certificate    /usr/local/www/ssl/server.crt;
55    ssl_certificate_key  /usr/local/www/ssl/server.key;
56
57    server_name  secure.domain.org;
58
59    keepalive_timeout 65;
60
61    location / {
62      root /usr/local/www/data;
63      index index.htm;
64    }
65
66    location /wiki/ {
67      alias /usr/local/www/dokuwiki/;
68      include   php_fastcgi_support;
69      index    doku.php;
70    }
71
72    if (!-f $request_filename) {
73      rewrite ^(/wiki/)(.*)?(.*)  $1doku.php?id=$2&$3 last;
74      rewrite ^(/wiki/)$ $1doku.php last;
75    }
76
77  }
78
79  }

php_fastcgi_support:

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

$document_root$fastcgi_script_name;
5 include fastcgi_params;
6 }

going to http://www.domain.org/ shows the wordpress site like it should
and wp-admin and the likes all seem to work (wonderful)

The part that is not working as desired is the ssl portion.

going to https://secure.domain.org works as intended; which is rendering
the contents of /usr/local/www/data trying to get to
https://secure.domain.org/wiki/(index.php) does not work at all.

I get the generic “no input file specified”.

192.168.10.199 - - [17/Dec/2009:14:39:28 -0500] “GET /wiki/index.php
HTTP/1.1” 404 62 “-”
192.168.10.199 - - [17/Dec/2009:14:40:40 -0500] “GET /wiki/doku.php
HTTP/1.1” 404 62 “-”

Can someone suggest what I might be doing wrong?

thanks in advance

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,31388,31388#msg-31388

On Thu, Dec 17, 2009 at 11:58 AM, mystique [email protected] wrote:

3  events {

14 access_log /var/log/nginx-access.log;
25 listen 80;
36
47 }
58
69 index doku.php;

192.168.10.199 - - [17/Dec/2009:14:40:40 -0500] “GET /wiki/doku.php HTTP/1.1” 404 62 “-”
[email protected]
http://nginx.org/mailman/listinfo/nginx

Helped on IRC; the problem was that the PHP location had a different
root from the wiki location, so we added another PHP location specific
to the wiki. A bit later I will be posting updated pretty-urls setup
to the wiki.

– Merlin

Hello!

On Thu, Dec 17, 2009 at 02:58:41PM -0500, mystique wrote:

[…]

66    location /wiki/ {
67      alias /usr/local/www/dokuwiki/;
68      include   php_fastcgi_support;
69      index    doku.php;
70    }

[…]

going to http://www.domain.org/ shows the wordpress site like it should and wp-admin and the likes all seem to work (wonderful)

The part that is not working as desired is the ssl portion.

going to https://secure.domain.org works as intended; which is rendering the contents of /usr/local/www/data trying to get to https://secure.domain.org/wiki/(index.php) does not work at all.

You have no root defined for location /wiki/. You use alias
instead, but alias a) isn’t inherited into nested location you use
to handle .php files and b) doesn’t affect $document_root variable
anyway. So

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

uses default root while resolving $document_root, which isn’t likely
what you want.

Try this instead:

location /wiki/ {
    alias /usr/local/www/dokuwiki/;
    index doku.php;

    location ~ ^/wiki(.*\.php)$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME  /usr/local/www/dokuwiki$1;
        include        fastcgi_params;

    }
}

Maxim D.

On Thu, Dec 17, 2009 at 2:22 PM, Maxim D. [email protected]
wrote:

   }

}

Maxim D.

We worked it out into a configuration very similar but not with the
sublocation (I considered that a mistake, though I know they work we
just aren’t “officially” supporting them yet, right?). Below I have
pasted the last known config.

server {
listen 443;
ssl on;
ssl_certificate /usr/local/www/ssl/server.crt;
ssl_certificate_key /usr/local/www/ssl/server.key;

root /usr/local/www;
server_name secure.domain.org;

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

keepalive_timeout 65;

location / {
root /usr/local/www/data;
index index.htm;
}

location /wiki {
alias /usr/local/www/dokuwiki;
index doku.php;
}

location ~ ^/wiki(/.*.php)$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/www/dokuwiki$1;
fastcgi_pass localphp;
}

location ~ .php$ {
include fastcgi.conf;
fastcgi_pass localphp;
}
}

– Merlin