Installing and Customizing MediaWiki

All you need to know to install and use the powerful MediaWiki system.
Virtual Servers

If you want to put the MediaWiki installation in a virtual server on an existing Apache installation, you need to modify the Apache configuration file to create a new virtual host on your system. Modern versions of HTTP require that a Web browser request a document from a specific hostname. The virtual host feature in Apache allows one Web server to serve documents for many different hostnames, even when all of the names resolve to a single IP address. If you just want to try MediaWiki without affecting the rest of your site, or if the majority of your site runs under a framework (such as Zope or Ruby on Rails) that is largely incompatible with MediaWiki, a virtual host might well be a wise move. I often use such virtual hosts to experiment with new software and configurations without potentially endangering existing, stable sites.

Apache's VirtualHost sections allow you to configure one or more such virtual servers, each with its own configuration. In configuring MediaWiki for my system, I needed the following VirtualHost section in httpd.conf:


<VirtualHost 69.55.225.93>

ServerName wiki.lerner.co.il
    ServerAlias mediawiki.lerner.co.il wikipedia.lerner.co.il
ServerAdmin reuven@lerner.co.il

DocumentRoot /usr/local/apache/v-sites/wiki.lerner.co.il/www/
DirectoryIndex index.php

CustomLog
/usr/local/apache/v-sites/wiki.lerner.co.il/logs/access-log combined
CustomLog
/usr/local/apache/v-sites/wiki.lerner.co.il/logs/referer-log referer
ErrorLog /usr/local/apache/v-sites/wiki.lerner.co.il/logs/error-log

</VirtualHost>

The first two lines of this VirtualHost section define the name and aliases for this new virtual server. By adding aliases, I ensure that even if people enter a different name, they will get to the right place. (Because I have asked my hosting company to alias all hostnames in the lerner.co.il domain to my server's IP address, I can add and remove new virtual hosts whenever I want, without having to modify the DNS configuration.) I then set ServerAdmin to be my own e-mail address, ensuring that error messages will direct people to me.

Next, I indicate that the root directory for the wiki—that is, where Apache should look for the PHP programs that define it—is under /usr/local/apache/v-sites, where I put all of the virtual servers on my machine. Each site then gets a subdirectory according to its name, with two directories (www and logs) under that. So in the above configuration, I have defined the DocumentRoot to be under v-sites/wiki.lerner.co.il/www, and I have put the access, referer and error logs under v-sites/wiki.lerner.co.il/logs.

Once I have added the above configuration to httpd.conf, I restart Apache. At this point, I'll get an error if I go to http://wiki.lerner.co.il, as I haven't yet installed the software.

To install the MediaWiki software, I download the latest .tar.gz file, and open it in the v-sites/wiki.lerner.co.il:

cd /usr/local/apache/v-sites/wiki.lerner.co.il/
tar -zxvf /downloads/mediawiki-1.5.3.tar.gz
mv mediawiki-1.5.3 www

After doing that, I pointed my Web browser to http://wiki.lerner.co.il, and got a message saying that I still needed to configure the software. But the permissions weren't set quite right, meaning that MediaWiki was unable to write to its configuration directory. Rather than aborting with a hard-to-understand error message, MediaWiki kindly told me that there was a problem with the filesystem permissions, and it even reminded me how to use chmod to fix the problem.

After having changed the permissions, MediaWiki then showed me the initial configuration screen. To be honest, I didn't have to do very much; I entered the name of my wiki (ReuvenWiki), and I kept the defaults for nearly everything else. I entered a password for the WikiSysop user within the wiki system itself. And, I entered a password for the database user and also entered the password for the MySQL administrative user.

Remember, you're keeping track of three types of user names here, which can be a bit tricky. Your Linux system has one set of users and permissions, MySQL has its own set of users and permissions, and the MediaWiki software also has its own set of users and permissions. Although this might seem like overkill, it provides a great deal of flexibility, allowing you to run MediaWiki in a safe, secure environment.

Once I filled out all of the above information, I clicked on the Install! button. Unlike many Web applications, which produce output only when they have finished with their work, the MediaWiki installer kindly provides updates as the installer is running, giving you a sense of what it is doing and how much longer you might have to wait. In the end, you should (hopefully) see a note indicating that the installation was successful, and that you should move config/LocalSettings.php into the parent directory (the www directory):

mv -v config/LocalSettings.php .

Having done that, I can re-enter the URL (http://wiki.lerner.co.il) into my Web browser. And, sure enough, I'm greeted by MediaWiki's initial page, which tells me that the software has been installed successfully and points me to two pages, one for customizing the interface and another describing usage and configuration.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Slight clarification in capitalization of call to addMessages

Anonymous's picture

In the text above: "Note that the page name must begin with a lowercase letter in the call to addMessages" doesn't appear to be correct, at least in MediaWiki 1.6.10 where I just tried it---it's not the -first letter- that must be lowercase, but the -entire name-. So if you have a function called MySpiffyPage and a corresponding page name, you need to say "$wgMessageCache->addMessages(array('myspiffypage' => 'My Spiffy Page'));" and not "$wgMessageCache->addMessages(array('mySpiffyPage' => 'My Spiffy Page'));"

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState