Installing MediaWiki into a FreeBSD Server
Scope of This Document
In this exercise, I will demonstrate the method I use to configure a MediaWiki installation on a FreeBSD server. I will assume that you have followed my methods already laid out in Installing FreeBSD 6.2, and then Deploying a FreeBSD 6.2 Server. Specifically, you will need to already have completed the installation of Apache 2.2, PHP5 (following carefully the directions to enable apache support, as well as upating the httpd.conf configuration file). In my Server document, MySQL was installed as part of an optional Cacti installation, so I will go over its installation below, in case the reader chooses not to install Cacti.
Getting The Database Server Installed
In the article Deploying a FreeBSD 6.2 Server, MySQL 5.0 was installed as part of the operation depicted here. The first step was to install MySQL. If you chose to not install the Cacti network graphing as the server document shows, then at this time you will want to install MySQL. If your system already has MySQL 5.0, then skip on down to the next part.
# cd /usr/ports/databases/mysql56-server; make install clean
Configure MySQL server to load at boot, add this to /etc/rc.conf:
echo 'mysql_enable="YES"' >> /etc/rc.conf
and then start MySQL
# /usr/local/etc/rc.d/mysql-server start
Now that all that is out of the way, on to building the MediaWiki port.
cd /usr/ports/www/mediawiki119; make BATCH=yes install clean cd /usr/ports/graphics/ImageMagick; make BATCH=yes install clean
Configuring a Database
First up, we will need a user for our database. I named mine 'wikiuser', and specified its shell as 'nologin' and its homedir as /nonexistant. For this example, we will give it password '123456'. Now that we have our database user and MySQL running, lets create the database. Be sure to give your database a name that makes sense for whatever you are doing (we will call this one 'wikidb').
mysqladmin --user=root create wikidb
Set the wikiadb database's permissions.
echo "GRANT ALL ON wikidb.* TO wikiuser@localhost IDENTIFIED BY '123456'; FLUSH PRIVILEGES;" | mysql
Configuring Apache for Your Wiki Site
We will need to add some items to our configuration file so that our MediaWiki install will work on our server. As previously noted, the file I make my Apache additions in is /usr/local/etc/apache22/Includes/httpd-local.conf, and this is what will be added:
<Directory /usr/local/www/mediawiki> AllowOverride None Order Allow,deny Allow from all </Directory> Alias /wiki /usr/local/www/mediawiki
The <Directory tells Apache to allow access to a folder outside the DocumentRoot, and the Alias line tells Apache to redirect requests asking for /wiki to pages served from the folder specified. If my server was www.ourexample.com, then our wiki URL would be:
Configuring your Wiki
If your configuration of Apache was correct, the first thing you should see when you go to your wiki URL is:
Please set up the wiki first.
Click on the link, it will take you to your configuration page, and it should look like this.
Don't be afraid of what you are seeing here, the Configuration is quite simple. Put in your Wiki Name and Contact Email. Language and Copyright License can stay how it is (well, unless you know you need to change them). Admin username, you can leave it as it is, or you can change it. You might want to leave it for now, and then add yourself as an editor later. Put in the password for the Admin account. Skip down to database config. The defaults that are there, we have already setup (wikidb, and wikiuser). Put in your password that you chose (hopefully you didn't choose 123456 like in the example here!). Our database is already created and should be ready to go, so omit putting anything in with the Superuser account section. Scroll down to the bottom, and click 'Install MediaWiki'. If something goes wrong, don't panic. Recheck your database user name and password, thats usually where the foul up is.
Now,copy the config/LocalSettings.php to the root of the wiki.
cp /usr/local/www/wiki/config/LocalSettings.php /usr/local/www/wiki/
Finally, reload your wiki page (or follow the link from after you clicked 'Install MediaWiki'
Lock Down Your Wiki
After you complete the setup on your site, I highly recommend that you add this to your LocalSettings.php file, or your wiki will surely be defaced within hours. My preferences are below, I disallow anonymous user creations and anonymous editing (which is against the basic idea of mediawiki, but because internet.
# Prevent new user registrations except by sysops $wgGroupPermissions['*']['createaccount'] = false; # Prevent Anonymous editing $wgGroupPermissions['*']['edit'] = false; $wgShowIPinHeader = false;