Scenario
- You have a nginx webserver
- You have several MediaWiki installation on this server
- You would like to have a simple and clear configuration
Solution
You want a configuration file you can include in every server {} block MediaWiki is available
Implementation
- Create a includes subdirectory in your nginx configuration directory (by default, /usr/local/etc/nginx or /etc/nginx).
This directory can welcome every configuration block you don’t want to repeat in each server block. - You put in this directory mediawiki-root.conf, mediawiki-wiki.conf or your own configuration block.
- In each server block, you can now add the following line:
Configuration I – MediaWiki in the root web directory, /article path
This is mediawiki-root.conf on my server:
Configuration II – MediaWiki in the /w directory, /wiki/article path
This is mediawiki-wiki.conf on my server:
Example of use
www.wolfplex.org serves other application is subdirectories and MediaWiki for /wiki URLs.
This server block:
- is a regular one
- includes our includes/mediawiki-wiki.conf configuration file (scenario II)
- contains a regular php-fpm block
- contains other instructions
Some notes
- Configuration is based on Daniel Friesen’s MediaWiki Short URL Builder, who collected various working nginx ones. There are some differences in the rewrite, our goal here is to have a generic configuration totally agnostic of the way .php files are handled.
- Our configuration (not the one generated by the builder) uses a if for the thumbnails handler. The nginx culture is a culture where you should try something else than an if. See this nginx wiki page and this post about the location if way of work for more information.