Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Just setup WikkaWiki on my server, I have been trying to have the links go from wiki.mysite.info/wikka.php?wakka=Start into wiki.mysite.info/DotMG.

I tried following their guide at http://docs.wikkawiki.org/ModRewrite, however it seems incomplete and outdated. Furthermore, as of version 1.3.2 base_url isn't even manually configurable from the wikka.config.php file.

I am using version 1.3.2 of WikkaWiki. My nginx virtual hosts file contains:

server {
    listen 80;

    server_name wiki.mysite.info;

    root /usr/share/nginx/wikka/;

    access_log /usr/share/nginx/.access/wikka;
    error_log /usr/share/nginx/.error/wikka error;

    location / {
            index index.php;
            try_files $uri $uri/ @wikka;
    }

    location @wikka {
            rewrite ^(.*/[^\./]*[^/])$ $1/ last;
            rewrite ^(.*)$ /wikka.php?wakka=$1 last;
    }

    location ~* \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
    }
}

Thus far it works, I can go to wiki.mysite.info/APage and it'll display that page, however it doesn't work on all pages, sometime the browser simply downloads the page (For some reason it always downloads the Start page).

Also when I go to wiki.mysite.info/ it downloads the wikka.php file...

Furthermore, the links on the wiki have the wikka.php?wakka= so whenever I navigate around the wiki, it goes back to being wiki.mysite.info/wikka.php?wakka=APage.

I think something is wrong with my rewrite but I can't say for sure.

Contents of the fastcgi_params:

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         $request_filename;
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   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

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   HTTPS                   $server_https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;
share|improve this question
    
Post your /etc/nginx/fastcgi_params? –  quanta Nov 27 '11 at 13:58
    
@quanta added to post :) –  Hans Nov 27 '11 at 17:06
    
@Hans You have to set up Wikka to use clean URL's, I'm not sure how its done though (never used Wikka). –  jli Nov 27 '11 at 18:18
    
@jli That's true, however that is also the problem, it would seem that the WikkaWiki devs removed that feature (base_url), not sure why though. However that is only half the problem, the other one is actual the downloading wikka.php. –  Hans Nov 27 '11 at 18:42

3 Answers 3

Change this line:

fastcgi_param   SCRIPT_FILENAME         $request_filename;

to:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

and try again.

share|improve this answer
    
Thanks quanta, I changed the fastcgi_params file, however that seems to have done nothing. Whenever I go to wiki.mysite.info/Start, it just downloads the file instead of parsing and displaying it... :( –  Hans Nov 28 '11 at 4:10
    
Did you restart nginx? –  quanta Nov 28 '11 at 4:15
    
yes I did, sudo service nginx restart. No errors occurred. –  Hans Nov 28 '11 at 5:22

I came here through Google, and despite I had to find the solution myself, and even this thread is more than 1 year old, I think I have to post here my solution for other folks brought here by Search Engine.

I think that in nginx, the rewriting to location @wikka done by try_files is short-circuiting the call to the block location ~ \.php

Re-copying everything from inside the block location ~ \.php into location @wikka solved the issue for me. More on http://blog.dot.mg/?t=20

share|improve this answer
    
I never thought of that, alas I haven't been using nginx anymore due to issues like this. Apache is still far easier to setup and maintain then nginx. Thanks anyway for the answer, I am sure that others will find this very useful. –  Hans Feb 3 '13 at 10:04

I've just finished migrating an old Wikka installation to 1.3.5 and from Apache to Nginx/php-fpm.

For reference here's my vhost definition with the appropriate rewrite rules:

server {
    listen      80;
    server_name wiki.domain.com;

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

    access_log  /var/log/nginx/wiki.domain.com.access.log;
    error_log   /var/log/nginx/wiki.domain.com.error.log;

    location / {
        index       wikka.php;
        try_files   $uri $uri/ @wikka;
    }

    location @wikka {
        rewrite (.*)    /wikka.php?wakka=$1;
    }

    location ~ \.php$ {
        try_files       $uri =404;
        fastcgi_pass    unix:/var/run/php5-fpm.sock;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.