Help:Apache config
From GRWiktionaryHelp
Apache webserver is the recommended web server for use with MediaWiki. Other servers may work, but who knows.
Contents |
Modules
PHP
You'll want to set up PHP as an Apache module, or likely you won't get anything running. ;)
Be sure to enable mod_php in the directory that contains the MediaWiki scripts, but you should also remember to disable it in the upload directory, so that visitors don't have the ability to execute arbitrary code on your system!
mod_rewrite
URL rewriting is recommended to make some of your URLs look much nicer. This is very installation-specific, but see the Rewrite rules page for some pointers.
mod_alias
Alternatively to using mod_rewrite, you may use mod_alias with similar effects. In this case it is assumed that mediawiki is not installed under apache's document root, but in some other directory, e.g. /usr/local/lib/mediawiki. Then you can add lines similar to the following example to your apache configuration:
<IfModule mod_alias.c>
Alias /mediawiki/ /usr/local/lib/mediawiki/
Alias /wiki/ /usr/local/lib/mediawiki/index.php/
Alias /wiki /usr/local/lib/mediawiki/index.php/
<Directory /usr/local/lib/mediawiki>
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory /usr/local/lib/mediawiki/images>
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
# avoid execution of PHP scripts in upload directory
AddType text/plain .php
AddType text/plain .phps
</Directory>
</IfModule>
As in the mod_rewrite example, wgScriptPath is now "/mediawiki", and wgArticlePath is "/wiki/$1".
Once you have made the changes to map index.php to the shorter url, you may need to clear your web browsers cache and the objectcache table to ensure that all links are correctly pointing to the shorter url. In some cases, the old links to index.php in combination with the Alias configurations above will cause MEdiaWiki to try and edit index.php itself, rather than the page or section you are really trying to edit.
Note that this section on mod_alias was not written by an apache/php expert, so you should check whether it's fitting your security demands.
Patches
If you're using URL rewriting and want to be able to use the ampersand (&) in page titles, you'll need to patch Apache to properly escape the character when generating the query string. A patch for Apache 1.3.26 is available as maintenance/apache-ampersand.diff in the MediaWiki source. (No patch is yet available for Apache 2.0.x.)
Change your mod_rewrite config like so:
RewriteEngine On
RewriteMap ampescape int:ampescape
RewriteRule ^/wiki/(.*)$ /w/wiki.phtml?title=${ampescape:$1} [L]
RewriteRule ^/wiki$ /w/wiki.phtml
This way, /wiki/AT&T correctly becomes /w/wiki.phtml?title=AT%26T instead of /w/wiki.phtml?title=AT&T, which breaks up into "title=AT" and a useless "T".
Robots exclusion file
You probably don't want spiders trying to download every dynamically generated page... see robots.txt
Throttling
See request throttling.
Reference implementation
For reference, here are the apache configuration files used for Wikimedia wikis:
- httpd.conf
- nonexistent.conf
- webshop.conf
- testwiki.conf
- redirects.conf
- main.conf
- remnant.conf
- boards.conf
- upload.conf
- wikimedia.conf
- foundation.conf
- en2.conf
- postrewrites.conf
Reading:
Go |
Search |
URL |
Namespace |
Page name |
Section |
Link |
Backlinks |
Piped link |
Interwiki link |
Redirect |
Variable |
Category |
Special page
Tracking changes:
Recent |
(enhanced) |
Related |
Watching pages |
Page history |
Diff |
User contributions |
Edit summary |
Minor edit |
Logging in and preferences:
Logging in |
Preferences |
User style
Editing: Overview |
Wikitext |
New page | List |
Images/files |
Image page |
Special characters |
Formula |
Table |
EasyTimeline |
Template |
Renaming / Moving a page |
Editing shortcuts |
Talk page |
Testing |
Export |
