0

I'm trying to setup a mediawiki under a subdirectory of nginx.

I don't want to use something like http://wiki.example.com. I don't want to proxy back to my server.

I want to use http://www.example.com/wiki or something similar.

I tried rewriting the php, but didn't workout very well. Here is what I tried:

 location /wiki {
     rewrite ^ /wiki/index.php$request_uri;
 }

I'm currently using Mediawiki 1.31.0.

Daniele Santi
  • 2,529
  • 1
  • 25
  • 22
  • If you don't want to use a subdomain, and you don't want to proxy... there aren't really any other options. – womble Sep 18 '18 at 10:26
  • Hm.. Is proxy only the way to solve mediawiki problem? (Or subdomain) – SmartPencil Sep 18 '18 at 10:33
  • If you have `nginx`, MediaWiki and PHP all working on the same server, you should be able to configure them to work under a subdirectory. I use the same structure as Wikipedia, with `/wiki/` for the article prefix and `/w/` for the script prefix. You might want to share more of your `server` block, and let us know which bits are working. – Richard Smith Sep 18 '18 at 11:20
  • I think you misunderstood my point (or I didn't get your point). I have some basic static page running on root directory. It's just a css js html combo. I am also running wordpress under /blog. What I want to do is install wiki on actual subdirectory. I think you're trying to tell me to add prefix to php request to look like a subdirectory. Sorry if I have misunderstood. – SmartPencil Sep 18 '18 at 12:42

1 Answers1

0

This is the most complete answer I can get so far. It doesn't seem to recognize the styles like Vector, but everything else appears to work for now. here is the entire Server Block:

server {
    listen 80;
    listen [::]:80;
    root /var/www/basedomain.org;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name basedomain.org *.basedomain.org;

    location / {
        try_files $uri $uri/ =404;
    }

    location /wiki {
        alias /var/www/mediawiki/code;
        index index.php index.html;
            if (-f $request_filename) {
                break;
            }
            rewrite ^/(.*)$ /wiki/index.php?title=$1&$args;
    }

    location ~ /wiki/(.+)\.php(/|$) {
        set $script $uri;
            if ($uri ~ "/wiki/(.+\.php)(/|$)") {
                set $script $1;
        }
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        fastcgi_param  SCRIPT_FILENAME  /var/www/mediawiki/code/$script;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
miken32
  • 942
  • 1
  • 13
  • 35