HOWTO:Creating a MediaWiki Site
From NEBL
MediaWiki is the free wiki software package well known because of its use for Wikipedia.
These instructions are how I set up this NEBL site, and are specific to the server environment we have in the Department of Computer Science & Engineering at the University of Nevada, Reno. They also assume that you are configuring the wiki as a sub-site, e.g. wrapping the wiki in a non-wiki home page. If these assumptions do not apply, you will have to modify various parts of the following instructions, tips, and examples.
Contents |
Installing
Ask your sysadmin for -
- a custom URL, if needed (nebl.cse.unr.edu in the examples below, with associated directory /web/htdocs/nebl/)
- a MySQL database, username, password, and server name for the wiki
- if you need or want to use an existing username/password, there's a prefix mechanism for keeping the wiki separate (see the MediaWiki internal documentation for details)
- a UNIX group that both you and the web server can be a member of (www-data in the examples below)
- this is for security (more below)
- a UNIX group for people who need back-end access to the system, if desired (nebl in the examples below)
Back up your MySQL database
- This is only needed if you are using a database that is shared by something other than the new wiki.
Fetch and unpack the installation kit
- If you're on the MediaWiki-announce mailing list, the update messages contain links to the latest kit, patches, checksums, etc.
- The examples below use version 1.11.0; modify as required.
- Fetch the .tar.gz and .patch files into the directory above where you want the wiki installed (e.g., in the home directory for the URL, if the wiki is going to be a sub-site).
- Strange... MediaWiki gives an error if you add examples using the w-g-e-t command in an example, or even in a comment!
- Verify the downloaded files, e.g. by comparing the output of these commands to what was in the e-mail announcement:
md5sum -b mediawiki-1.11.0.tar.gz
md5sum -b mediawiki-1.11.0.patch
- Unpack the software:
tar -xzf mediawiki-1.11.0.tar.gz
- Rename the resulting directory. If you are going to use URL prettification, use a directory name different from what you want viewers to see.
mv mediawiki-1.11.0 public-wiki
pushd public-wiki
- Apply the patch, if needed. (In the case of 1.11.0 the patch had already been applied to the kit, but here's how you would do it if you needed to:)
patch -p0 <../mediawiki-1.11.0.patch
- If a special group of people will need to be able to do back-end maintenance, set the group ownership of the files in the tree:
chown -R :nebl *
- Clean up the installation media:
rm ../mediawiki-1.11.0.*
- See what's new:
more RELEASE-NOTES
- Take a peek at the installation instructions to make sure nothing big has changed.
- If you are not already subscribed to the MediaWiki announcements mailing list, the instructions are in this file. You may want to go ahead and sign up now.
more INSTALL
Base configuration
N.B. - Once you start this you will need to continue down through the Security Configuration section before you stop.
- Make the configuration directory writable by the Web server:
chmod a+w config
- Load the URL (e.g., http://nebl.cse.unr.edu/public-wiki/) in your browser and follow the instructions as it runs the configuration script.
- It will create a wiki account named WikiSysop by default. At present I do not see any reason not to create an account for yourself instead, if you are the one with primary responsibility for maintaining the wiki.
- When prompted by the script in your browser, do this back at the prompt on the server:
cp config/LocalSettings.php .
- Set the ownership of LocalSettings.php to the group that both you and the Web server can read, and then tighten up the permissions on the file.
- This is needed because the Web server must be able to read the file, but it contains the MySQL username and password in plaintext, and thus you may not want just anyone with an account on the server to be able to read it.
chown :www-data LocalSettings.php
chmod g-w LocalSettings.php
chmod o-rwx LocalSettings.php
- The resulting permissions should look something like this, except with you as the owner:
ls -l LocalSettings.php
-rw-r----- 1 bdbryant www-data 4336 Oct 14 20:37 LocalSettings.php
- Lock the config directory back down as well:
chmod go-rwx config
- Be sure to continue through the Security Configuration section right now.
Site Version Control
The wiki does its own version control on its content. However, it does not track changes to the configuration files. If the wiki area is a sub-site and the outer site is under version control, you might want to add LocalSettings.php to your repository before you start modifying it. (There does not seem to be any need to put the entire wiki directory under version control.)
If you have your version control repository set up to automagically update the production site whenever you check in a change, you need to make sure it leaves LocalSettings.php with the correct ownership and permissions when it is done. (I recommend setting it up that way, both as a labor saver and as a guard against accidentally leaving it with the wrong protections after changing it by hand.)
Here is an example of what to do if your site is already under SVN control:
- Check out the site somewhere.
- In the checked-out directory do -
mkdir public-wiki/
scp banyan.cse.unr.edu:/web/htdocs/nebl/public-wiki/LocalSettings.php public-wiki/
svn add public-wiki/
svn commit -m "Added the configuration file for the public wiki."
- Then in the repository itself (not the checked-out copy), make the automagic export instructions in hooks/post-commit look something like this:
svn export --force file:///staff/bdbryant/repositories/svn/nebl-www/ /web/htdocs/nebl/
chown :www-data /web/htdocs/nebl/public-wiki/LocalSettings.php
chmod o-rwx /web/htdocs/nebl/public-wiki/LocalSettings.php
Security Configuration
Unless someone is going to monitor the wiki very thoroughly, you want to keep anonymous editing and account creation turned off. (Otherwise spammers' bots will find your site and modify it for their own purposes.)
If you did not specify your own account as the sysop during the on-line configuration, you may want to create your personal account before turning account creation off.
- Load the wiki in a browser and use the link in the upper right corner of the page to create your account.
Now add this to LocalSettings.php:
## Account permissions $wgGroupPermissions['*']['createaccount'] = false; $wgGroupPermissions['sysop']['createaccount'] = true; #-- $wgGroupPermissions['*']['createpage'] = false; $wgGroupPermissions['user']['createpage'] = true; #-- $wgGroupPermissions['*']['delete'] = false; $wgGroupPermissions['user']['delete'] = false; $wgGroupPermissions['sysop']['delete'] = true; #-- $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['user']['edit'] = true;
That means that only people logged in to a wiki account can create or edit pages, and only someone logged in with sysop privileges can create an account or delete a page.
Save the file and upload it to the server right now.
- See, if you had set up version control you wouldn't have to worry about the uploaded file's ownership and permissions.
Now it is locked down (I hope!), and you can continue with the customizations at your leisure. However, some of the customizations should be done before you add any content. Skim the following section before you start.
Customization
Prettifying the URLs
N.B. - Do this before you link to the site or create any content.
There are several ways to do this; see http://www.mediawiki.org/wiki/Manual:Short_URL for examples.
- If you use a method based on .htaccess, consider putting it under version control.
At cse.unr.edu, the .htaccess mechanisms will only work if your wiki is under public_html in a user's directory tree. If you have a custom URL your files are probably under /web/htdocs/, and you will have to use the following mechanism:
- Have the sysadmin enable URL rewrites on the server. The rule you need will look something like this:
<Directory "/web/htdocs/nebl/">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.*)$ public-wiki/index.php?title=$1 [PT,L,QSA]
</Directory>
- Add to the wiki's LocalSettings.php:
$wgArticlePath = "/wiki/$1";
- Now you can start creating content.
- External links into the wiki should use the form http://nebl.cse.unr.edu/wiki/Article to link to a page in the wiki named article.
Creating Additional Namespaces
N.B. - This can also save some trouble if you do it before much content is added, but you may not know at first what kind of namespaces you will want.
A namespace is a keyword followed by a colon prefixed to an article's title. For example, this page is in the HOWTO: namespace.
The on-line MediaWiki manual lists the predefined namespaces and tells how to add your own custom namespaces.
- Regarding the latter, if you are not a PHP programmer, be aware that this line in their example adds a new element to the end of a dynamic array, with a value of 100 and an unknown index:
$wgContentNamespaces[] = 100
- Thus if you want to add several custom namespaces and identify them as content areas you will have to have several lines similar to that one. For example, the NEBL site has namespaces called HOWTO: and Notes: that are both to be reckoned as content areas, and thus required the following additions to LocalSettings.php:
$wgExtraNamespaces[100] = "Notes";
$wgExtraNamespaces[101] = "Notes_talk";
$wgExtraNamespaces[102] = "HOWTO";
$wgExtraNamespaces[103] = "HOWTO_talk";
$wgContentNamespaces[] = 100;
$wgContentNamespaces[] = 102;
Changing the Theme
To change the default layout of the pages rendered by the wiki engine, change $wgDefaultSkin in LocalSettings.php.
- Pick one of the predefined names.
- You can also create a new theme, if you wish.
- Users can override the default theme, unless you disable that option.
- See the on-line MediaWiki manual for more information.
Changing the Logo
Some of the themes, such as standard show a logo. The installation provides a placeholder logo that you will need to replace.
The standard them expects a PNG logo 135 pixels wide. If you vary from that very much it may not look right in the layout of rendered pages.
When you have created your new logo, point to it by changing $wgLogo in LocalSettings.php. The logo file can be outside the wiki if you wish.
Hint: For a quick fix, just use a grapics program to create an image 135 pixels wide with your site's acronym centered in the image, in color, and a transparent background. That lets you get rid of the placeholder logo with minimal trouble; you can create a custom logo when time allows.
Customizing the Sidebar
This can only be done from an account with sysop privileges.
Open the MediaWiki:Sidebar page at your site (type it in the search field of any page in the wiki), then edit it to show the desired layout. The edit will mostly consist of removing links you do not want, e.g. the link to the donation page if you are not taking donations.
If the wiki's main page is masked by a non-wiki home page, you can change "Main Page" to "Home" and link it in the usual fashion.
See http://nebl.cse.unr.edu/wiki/MediaWiki:Sidebar for an example.
Replace placeholder content
Several default pages were created by the installation but contain throw-down content that you should replace before too many people visit the site. These include various links that show up along the top, bottom, and sides of every page in the wiki, such as:
- Main Page
- Disclaimers
- Privacy Policy
- About
- possibly others
Provide a users' guide
Unless all your users are already expert MediaWiki editors, it will be useful to provide a page of links to various help and tips pages. See Site Maintenance Links for an example
Creating Accounts
See the instructions at Site_Maintenance_Links.
![[Main Page]](http://nebl.cse.unr.edu/logo.png)