How to Set Up your Own Personal Wiki.


Written by:

Robert McIntyre

Initially, this is going to be a guide for myself and my hacker friends to set up their own wiki. Eventually this will become a friendly guide that anyone should be able to use. If you'd like to help with this project, please send email to <>.

Last time I showed you how to set up your own server running Arch GNU/Linux. Today we're going to build off of that and make our own wiki, just like Wikipedia!

I will recommend various services in this article, because they are services that I use personally. You can of course substitute these for whatever you want.

1 A Wiki involves three core pieces of software:

1.1 A Database

Is a set of programs and files on your server that stores data in a highly ordered way and provides fast access to the data. The data is often arranged in a structure called a Table. Individual entries in the table are called Records or Rows. Programs are able to create Tables and Records in similar ways to how they create files. Like files, Tables have specific owners and permissions, so that only certain users and programs are able to access them. The important difference between a Table and a file is that a Table enforces constraints on the information inside it. A Wiki program might have many different tables in the database : one for handling users and passwords, one for handling the content of the wiki pages, and still another for handling administrative settings for the wiki as a whole. MySQL (, postgreSQL ( and MongoDB ( are all examples of database programs. We will be using MariaDB (a version of MySQL) for our media wiki installation because that is what Wikipedia uses.

1.2 Wiki Software

This is a set of programs that access the database and generate the HTML that will be delivered for any given page on the Wiki. These programs also write to the database whenever a page needs to be updated. Wiki software often includes images and CSS stylesheets to give a Wiki a basic style as well. We'll be using MediaWiki ( for our Wiki Software.

1.3 Web Server

A web server is like an email server in that it is always listening for input. An email server listens for emails, and a web server listens for people requesting a page. Your web server is the guardian and lens through which you present information from your server to the Web. It takes requests for pages such as and returns information depending on how you have configured it. You can configure a Web Server to do just about anything in response to a request for a page. A basic setup involves simply serving a folder of files from your computer to the world, and giving a 404 error if someone requests something that isn't there. In our case, we will configure the Web Server to accept addresses like and request the Wiki Software to generate HTML appropriate for that address. You can configure a Web Server to run any program to generate responses to page requests, even one you write yourself! Whenever you visit a page on the internet, you can be sure that you are interacting with a Web Server program running on a computer connected to the internet. We will be using lighttpd ( because is is easy to configure. Other web servers include Apache ( and Nginx (

2 Prepare your Server

Now you will get yourself your own personal server and your own domain, both of which are required for running a public wiki. If you already have a domain name and a server, or if you just want to configure a wiki for use on your own computer only, skip down to the "Install MySQL" section.

3 Get a Domain Name

You can buy a domain name from A domain name is like your personal name/the name of your house on the internet. My main domain name is "", because it means "little gold", and because it sounds like my initials, RLM. The steps to getting a domain name for yourself are as follows:

1.) Decide on a domain name. This is an important name that you might be using for a long time, so choose wisely. Be prepared to try multiple variations on your domain name as many domain names are already taken.

2.) Go to and register the domain name. The cost is about $12 per year for a domain name.

4 Get a Virtual Private Server

I recommend Linode, since you can load the server you get with my favorite operating system, Arch GNU/Linux, and because I have experienced stellar service from them for about a year so far.

Steps towards getting a Virtual Private Server:

1.) Go to and buy a Virtual Private Server of your very own.

  • Select the Operating System as "Arch Linux", and set the physical location to the nearest location to you. You will then decide how to partition your server; the defaults that Linode offers are fine. Finally, you will have to set the root password which is how you will access the server from your computer. Be sure to choose a secure password or your server can be easily compromised.

5 Link your domain name with your new server.

This is a two step process – you have to set your domain to point to the nameservers at, and you have to tell to point requests to your new virtual private server that you just bought.

1.) Go to again, select your domain, go to "Domain Name Server Setup", select "Specify Custom DNS Servers" and enter:


    as the 5 DNS servers.

2.) Go back to and go to the "DNS Manager". Select "Add a domain zone" and enter your domain name. Select the defaults to get yourself started.

It may take up to a day for the DNS system to sort itself out and for the entire world to recognize that your new domain name points to your new virtual private server.

After that, you will be able to ssh into your new server using your new domain name. Once you are able to do this, you know that you have properly set up your domain name and new server.

6 Configure A records for your machine to create a "wiki" subdomain.

The point of this section is to create the "wiki.<your-domain-name>" domain. I like this setup for aesthetic reasons because it keeps your domain name open for other services you might install in the future, such as webmail at "email.<your-domain-name>" or an FTP server at "ftp.<your-domain-name>". If you want your new domain name to serve as a wiki exclusively, feel free to adjust these directions accordingly. On my system visiting will bring you to the wiki, while will take you to this blog.

1.) Go to and select DNS Manager.

2.) Click "Add a domain zone" at the bottom right corner of the screen and enter the following values.

Domain: wiki.<your-domain-name>
SOA email: <your email>

Select "Yes, insert a few records to get me started", using the default IP suggested.

3.) Delete the "mail" A Record, the "www" A Record, and the "mail.<your-domain>" MX Record. (This is not strictly necessary, I just like to keep the records clean).

7 Set up your new sever.

Login to your shiny new server by using:

ssh root@<your-domain>

You should fully upgrade your system by performing:

pacman -Syyu

Now, you will want to create a new user for your machine.

useradd -m --groups wheel <your-username>

Finally, log off and log back on again as your new user.

ssh <your-username>@<your-domain>

8 Install MySQL, a database program

sudo pacman -S mariadb libmariadbclient mariadb-clients

9 Configure MySQL

Tell systemd to start MySQL when the system starts.

sudo systemctl enable mysqld.service

MySQL is like a file system, and just like the filesystem on your server, MySQL needs to have a root user that can access everything and create new users.

To create sensible defaults and a root user for your MySQL database, run:

sudo systemd start mysqld

Note that when the script says:

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

It is talking about the root user for the MySQL system, NOT the root user for your server. You should just press enter and not enter the password for the root user on your system.

When it says:

Set root password? [Y/n]

Select "Y" and create a new password for the root MySQL user. As with all passwords, I recommend that you set the root password on your MySQL database to a passphrase that is easy for you to remember but hard for anyone to guess. Four random English words such as "meticulous cougars flavorsome waltzing" should work very well and be essentially impossible to break. (Don't actually use "meticulous cougars flavorsome waltzing" now that I've written it here.) You should avoid using the same password for both your root server account and your MySQL account so that if someone compromises your wiki, they don't also get access to your server. Be sure to remember this root password as you will need it later to set up your wiki!

Select "Y" for the rest of the options to remove unnecessary database elements created when MySQL was installed.

Now, restart MySQL for your changes to take effect.

sudo systemctl restart mysqld

Check to make sure that MySQL is running by executing:

systemctl status mysqld

The first few lines of output on my system look like this:

systemctl status mysqld
mysqld.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
   Active: active (running) since Sat 2013-08-31 18:00:38 EDT; 7min ago

Make sure that it says "Active: active (running)".

10 Install php, a "programming language".

sudo pacman -S php php-cgi php-xcache php-gd php-intl

These programs provide the php language as well as several helper programs needed for our mediawiki.

php base php system
php-cgi makes php faster by keeping php always ready
php-xcache makes php faster by caching common requests
php-gd interface for graphics in php
php-intl internationalization for php (displaying messages in different languages)

11 Configure /etc/php/php.ini

php is controlled by a global config file called php.ini. This file specifies which capabilities the php language will have on your system. Since we're setting up a wiki, we'll need to enable graphics, mysql, and a few other capabilities.

Locate the "Dynamic Extensions" section of /etc/php/php.ini.

It begins with

; Dynamic Extensions ;

Uncomment the following lines:

Add the following line at the end of the Dynamic Extensions section:

The Dynamic Extension section should now look like this:

; Dynamic Extensions ;

; If you wish to have an extension loaded automatically, use the
; following syntax:
;   extension=modulename.extension
; For example, on Windows:
;   extension=msql.dll
; ... or under UNIX:
; ... or with a path:
;   extension=/path/to/extension/
; If you only provide the name of the extension, PHP will look for it
; in its default extension directory.

12 Install MediaWiki software and related files.

sudo pacman -S imagemagick mediawiki

You may eventually host many websites and many wikis from your server, and accordingly, you should make things easier for yourself and setup your first wiki so that you can easily make more of them in the future. (Instead of setting it up so that you can only serve a single wiki from your machine.)

Choose a directory on your system that will serve as the base directory for your system. On my system, my user is called r, and I use /home/r/wiki/aurellem to serve Other wikis I host get their own directory in /home/r/wiki. If your domain was and your username on your server was catz, you might consider using /home/catz/wiki/lolcatsforever as the base folder for the wiki at Whatever you pick is entirely your choice, and from now on I'll refer to the directory you chose as <wiki-base>.

You will now need to create <wiki-base> and link some files to prepare your wiki.

mkdir -p <wiki-base>
cd <wiki-base>
ln -s /usr/share/webapps/mediawiki/* .
rm images
mkdir images
sudo chown :http images
chmod g+w images

This creates symlinks from the files you installed from the mediawiki package to your <wiki-base>. You create symlinks instead of copying the files so that whenever you upgrade mediawiki, the files for all of your wikis will be updated as well.

You remove the symlink to /usr/share/webapps/mediawik/images and replace it with a folder of the same name because mediawiki stores images related to a wiki in the images folder and thus each wiki needs its own images folder.

The chown and chmod commands enable lighttpd to access the images folder an put images into it whenever someone uploads an image to your wiki.

13 Install lighttpd, a powerful Web Server.

sudo pacman -S fgci lighttpd

Instruct systemd to start lighttpd on boot.

sudo systemctl enable lighttpd

Start the lighttpd server.

sudo systemctl start lighttpd

14 Configure /etc/lighttpd/lighttpd.conf

The config file for lighttpd is the most complicated file to prepare because lighttpd can do so many different things.

A minimal wiki config for lighttpd follows. Replace <your-domain> and <wiki-base> with the appropriate values and replace /etc/lighttpd/lighttpd.conf with the following:

server.modules    = (

server.document-root    = "/srv/http"
dir-listing.activate    = "enable"

server.port         = 80
server.username     = "http"
server.groupname    = "http"

server.errorlog     = "/var/log/lighttpd/error.log"

index-file.names    = ( "index.html", "index.php" )

mimetype.assign     = ( ".html" => "text/html", 
                        ".txt" => "text/plain", 
                        ".jpg" => "image/jpeg", 
                        ".png" => "image/png", 
                        ".css" => "text/css",
                        ".php" => "text/x-php",
                        "" => "application/octet-stream" )

fastcgi.server = ( ".php" => ((
       "bin-path" => "/usr/bin/php-cgi",
       "socket" => "/tmp/php.socket"))) 

$HTTP["host"] =~ "^wiki.<your-domain>*" {
       server.document-root  = "<wiki-base>"

Be sure to replace <your-domain> and <wiki-base> above with the appropriate values for your system.

For example, on my system, I use:

$HTTP["host"] =~ "^*" {
       server.document-root  = "/home/r/wiki/aurellem"


sudo systemctl restart lighttpd

To restart lighttpd with the new settings, and then check

systemctl status lighttpd

To confirm that lighttpd is still running.

15 Configure Your Wiki

Now you can visit http://wiki/.<your-domain> and configure your new wiki. You should be greeted with something that looks like this.


Figure 1: Your new Wiki awaits.

Click and follow the on screen directions.

Below are the settings I used on for my own wiki. Modify yours accordingly.

15.1 'Connect to database' section

Database host: localhost
Database name: aurellem
Database table prefix: aurellem
Database username: root
Database password: <MySQL root user password>

15.2 'Database settings' section

Use the same account as for installation UNCHECKED
Database username aurellem
Create the account if it does not already exist CHECKED
Storage Engine InnoDB
Database character set Binary

15.3 'Name' section

Name of wiki aurellem
Project namespace Same as the wiki name: Aurellem
Ask me more questions. CHECKED

15.4 Options

Enable file uploads CHECKED
Enable Instant Commons CHECKED
Settings for object caching: PHP object caching (APC, XCache or WinCache)

16 Upload LocalSettings.php

The configuration will end by offering you a file called LocalSettings.php.

Save this file to your computer and then upload it by opening a terminal, changing to the directory into which you downloaded LocalSettings.php, and executing:

scp LocalSettings.php <your-server-username>@<your-domain>:<wiki-base>

on my system, I executed:

scp LocalSettings.php

17 Configure your Wiki Logo

Create a logo image and upload it to your wiki base with

scp <your-logo-image> <your-server-username>@<your-domain>:<wiki-base>

I used the following image: sun.png

and executed:

scp sun.png

Then edit <wiki-base>/LocalSettings.php and find the part where it defines $wgLogo

I changed mine from :

$wgLogo             = "$wgStylePath/common/images/wiki.png";


$wgLogo             = "/sun.png";

Notice that the initial "/" is required.

18 Exploring Your New System

Congratulations! You have a shiny new wiki that your and your friends can edit and use to collaborate.

Here are a few commands that you can use to examine your new system.

18.1 Lighttpd

To get the status of lighttpd, use:

systemctl status lighttpd

You can also check /var/log/lighttpd/error.log for useful information.

cat /var/log/lighttpd/error.log

If you can't access your wiki at all for some reason, these are the first things to check.

18.2 MySQL

You can use the terminal to access your MySQL database and examine the tables and records there. Here's an example session of me interacting with my server.

[dark-star ~] $ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 221
Server version: 5.5.32-MariaDB-log Source distribution

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

MariaDB [(none)]> show databases;
| Database           |
| information_schema |
| aurellem           |
| mysql              |
| performance_schema |
4 rows in set (0.00 sec)

MariaDB [(none)]> use aurellem;
Database changed
MariaDB [aurellem]> show tables;
| Tables_in_aurellem         |
| aurellemarchive            |
| aurellemcategory           |
| aurellemcategorylinks      |
| aurellemchange_tag         |
| aurellemexternal_user      |
| aurellemexternallinks      |
| aurellemfilearchive        |
| aurellemhitcounter         |
| aurellemimage              |
| aurellemimagelinks         |
| aurelleminterwiki          |
| aurellemipblocks           |
| aurellemiwlinks            |
| aurellemjob                |
| aurelleml10n_cache         |
| aurellemlanglinks          |
| aurellemlog_search         |
| aurellemlogging            |
| aurellemmodule_deps        |
| aurellemmsg_resource       |
| aurellemmsg_resource_links |
| aurellemobjectcache        |
| aurellemoldimage           |
| aurellempage               |
| aurellempage_props         |
| aurellempage_restrictions  |
| aurellempagelinks          |
| aurellemprotected_titles   |
| aurellemquerycache         |
| aurellemquerycache_info    |
| aurellemquerycachetwo      |
| aurellemrecentchanges      |
| aurellemredirect           |
| aurellemrevision           |
| aurellemsearchindex        |
| aurellemsite_stats         |
| aurellemtag_summary        |
| aurellemtemplatelinks      |
| aurellemtext               |
| aurellemtranscache         |
| aurellemupdatelog          |
| aurellemuploadstash        |
| aurellemuser               |
| aurellemuser_former_groups |
| aurellemuser_groups        |
| aurellemuser_newtalk       |
| aurellemuser_properties    |
| aurellemvalid_tag          |
| aurellemwatchlist          |
49 rows in set (0.00 sec)

MariaDB [aurellem]> select user_name from aurellemuser;
| user_name       |
| Rlm             |
| Robert McIntyre |
2 rows in set (0.00 sec)

At this point I went to and created a new user named "new-user". Then in this same SQL session I executed the select command again.

MariaDB [aurellem]> select user_name from aurellemuser;
| user_name       |
| New-user        |
| Rlm             |
| Robert McIntyre |
3 rows in set (0.00 sec)

MariaDB [aurellem]> quit;

Notice how the users table changes when I add a new user to the wiki!

18.3 <wiki-base>

You can always check the images you and others have uploaded by going to <wiki-base>/images and running tree. If you don't have the program tree, install it with.

sudo pacman -S tree

When I execute

tree /home/r/wiki/aurellem/images

I see:

|-- archive
|   `-- e
|       `-- e1
|-- deleted
|   `-- 3
|       `-- t
|           `-- z
|               |-- 3tz2h6a0r28vsaj39rd9zd939v4ylyi.jpg
|               `-- index.html
|-- e
|   `-- e1
|-- lockdir
`-- thumb
    |-- 5
    |   `-- 5b
    |       `-- Name.jpg
    |           |-- 120px-Name.jpg
    |           `-- Name.jpg
    |-- a
    |   `-- a9
    |       `-- Example.jpg
    |           |-- 116px-Example.jpg
    |           `-- Example.jpg
    `-- e
        `-- e1

19 directories, 6 files

You can delete images for good by going to the images directory and removing them.

19 How to Backup your Wiki

Disks fail, companies go out of business, and you may be hacked at some point, so you should know how to backup your wiki and also how to restore it from the backup. In contrast to normal files, in order to backup your wiki you have to use a specialized MySQL "data dumper" to get the information contained in your MySQL database.

To backup your database, use:

mysqldump -u root -p <wiki-database-name> > <backup-file-name>

On my system, this command is:

mysqldump -u root -p aurellem > aurellem-wiki-backup.sql

The wiki database name is the name you selected for the database when installing your wiki. If you don't remember it then you can execute:

mysql -u root -p

And then enter:

show databases;

at the SQL prompt.

The backup file is a human readable sequence of SQL statements that together restores the wiki's tables when executed. Take a look at it – it's quite interesting. You can only run this command from your server, but once you have generated the backup file, you should copy it to another location to protect from the possibility of your server being destroyed.

To restore your wiki after a catastrophic failure, run the following commands.

First, an empty database with the same name as your wiki database.

mysql -u root -p

At the sql prompt, type:

create database <wiki-database-name>;

On my machine I typed:

create database aurellem;

The output should be:

Query OK, 1 row affected (0.00 sec)

Then, restore the contents of your wiki database from backup:

At a terminal prompt, type:

mysql -u root -p <wiki-database-name> < <backup-file-name>

On my machine this command would be:

mysql -u root -p aurellem < aurellem-wiki-backup.sql

Your wiki database will be restored.

You will also want to backup the files in <wiki-base>. You can do this by simply copying them to another computer. One nice way to do this is:

tar cvjf "wiki-backup-`date`.tar.bz2" <wiki-base>

This will create a dated archive file with all your wiki files (including symlinks) which you can restore anytime by unpacking the archive file with:

cd <wiki-base>
cd ..
tar xvf <your-arvhive-file>

20 How to create more Wikis

Now that you've created one wiki, creating another one can be done in 5 minutes or less. Here are the steps.

20.1 Create an appropriate A record for your new wiki's subdomain

For the purposes of this we'll use

20.2 Decide on a directory to serve as the base for your new wiki.

For example /home/r/wiki/new-site

20.3 Add an entry to /etc/lighttpd/lighttpd.conf

In this case we would use the following:

$HTTP["host"] =~ "^*" {
    server.document-root  = "/home/r/wiki/new-site"

20.4 Symlink files from /usr/share/webapps/mediawiki/ to your wiki base

You also have to set proper permissions in the images folder in your new wiki base. In this case, I would execute:

mkdir -p /home/r/wiki/new-site
cd /home/r/wiki/new-site
ln -s /usr/share/webapps/mediawiki/* .
rm images
mkdir images
sudo chown :http images
chmod g+w images

20.5 Complete wiki configuration from your browser.

I would go to and complete configuration, then upload the generated LocalSettings.php to my server with:

scp LocalSettings.php

21 Source Listing

Author: Robert McIntyre

Created: 2015-05-03 Sun 17:18

Emacs 24.4.1 (Org mode 8.3beta)