Mediawiki + nginx

still sorta confused about running those two together. my end goal is
to have simple urls like:

wiki.something.com/TheArticleThingie

right now under my current configs i get urls that look like this:

wiki.something.com/index.php/TheArticleThingie

which is very close but not quite.

To prove that i’ve done my share of “just google it”

i tried to cut&paste the configs from
http://wiki.nginx.org/NginxMediaWiki and when i do an nginx -t it
gives and error:

–snip–snip–snip–
tina:/etc/nginx/vhosts# nginx -t
2009/04/28 20:32:25 [emerg] 1172#0: invalid number of arguments in
“rewrite” directive in /etc/nginx/vhosts/wiki.sunlightlabs.com.conf:22
2009/04/28 20:32:25 [emerg] 1172#0: the configuration file
/etc/nginx/nginx.conf test failed
–snip–snip–snip–

–snip–snip–snip–
server {
listen 80;
server_name wiki.something.com;

http {

    root  /var/www/wiki.something.com/www/;

    location / {
        index index.php;

        if ($uri ~ "index.php/") {
            rewrite ^/index.php/(.+) /index.php?title=$1 last;
        }

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

    # .php5 sent to php5
    location ~ .*\.php$ {
        include /etc/nginx/fastcgi.conf;
        fastcgi_index index.php;

        if ($uri !~ "^/images/" ) {
            fastcgi_pass  127.0.0.1:10000;
        }
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param PHP_SELF /index.php;
        fastcgi_param SCRIPT_URL /index.php;
    }
 access_log /var/log/nginx/something_wiki_access.log combined;
 error_log /var/log/nginx/something_wiki_error.log error;

}

}

vim: set ft=nginx:

–snip–snip–snip–

–timball

On Tue, Apr 28, 2009 at 1:45 PM, Timothy B. [email protected] wrote:

To prove that i’ve done my share of “just google it”

i tried to cut&paste the configs from
http://wiki.nginx.org/NginxMediaWiki and when i do an nginx -t it
gives and error:

this is all i have:

    rewrite ^/wiki/([^?]*)(?:\?(.*))? 

/mediawiki/index.php?title=$1&$2 last;
rewrite ^/wiki /mediawiki/index.php last;

of course, that assumes

a) mediawiki is installed in /mediawiki
b) your “public” prefix is /wiki

You want no /wiki in the mix, so I am not sure how that would work
exactly. I would think it might become a circular rewrite.

You could take out /wiki in my example and try it out.

try_files would be another one to try, but that won’t work; mediawiki
wants the index.php?title= stuff in there.

On Tue, 2009-04-28 at 16:45 -0400, Timothy B. wrote:

To prove that i’ve done my share of “just google it”

i tried to cut&paste the configs from
http://wiki.nginx.org/NginxMediaWiki and when i do an nginx -t it

Please try the second example on that page and let me know how that
works. That’s the config I use for the Nginx wiki itself, so I expect
it works =)

Cliff

On Tue, Apr 28, 2009 at 04:45:17PM -0400, Timothy B. wrote:

2009/04/28 20:32:25 [emerg] 1172#0: the configuration file

    }
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param PHP_SELF /index.php;
        fastcgi_param SCRIPT_URL /index.php;
    }
 access_log /var/log/nginx/something_wiki_access.log combined;
 error_log /var/log/nginx/something_wiki_error.log error;

}

}

vim: set ft=nginx:

If you have “if ($uri” in configuration, this means that your
configuraiton
is far from optimal and has hidden agendas.

   location / {
       try_files  $uri  ${uri}index.php  /index.php?title=$uri;
   }

   location /images/ {
       # empty
   }

   location ~  ^/index.php/(.+) {
       rewrite ^/index.php/(.+) /index.php?title=$1 last;
   }

   location ~ .*\.php$ {
       fastcgi_pass  127.0.0.1:10000;
       ...
   }

On Tue, Apr 28, 2009 at 02:20:32PM -0700, Cliff W. wrote:

which is very close but not quite.

To prove that i’ve done my share of “just google it”

i tried to cut&paste the configs from
http://wiki.nginx.org/NginxMediaWiki and when i do an nginx -t it

Please try the second example on that page and let me know how that
works. That’s the config I use for the Nginx wiki itself, so I expect
it works =)

Please change this ugly stuff:

location ~ .*.php5?$ {
include fastcgi.conf;
fastcgi_index index.php;
if ( $uri !~ “^/images/” ) {
fastcgi_pass 127.0.1.1:1026;
}
}

to something like this:

location ~ .php5?$ {
fastcgi_pass 127.0.1.1:1026;
include fastcgi.conf;
}

location /images/ {
}

On Wed, 2009-04-29 at 10:29 +0400, Igor S. wrote:

wiki.something.com/index.php/TheArticleThingie
it works =)

to something like this:

location ~ .php5?$ {
fastcgi_pass 127.0.1.1:1026;
include fastcgi.conf;
}

location /images/ {
}

I’ve just removed the entire first example. I don’t know that it’s
worked for anyone.

Cliff