Installing MediaWiki on Ubuntu 14.04 with Lighttpd

About

MediaWiki

Some highlights of MediaWiki:

  • Founded in
  • Open Source
  • Wiki
  • Written in PHP

Additionally you can read more about this project here.


Lighttpd

This is a product that focuses on efficiency and handling higher server load. The p is silent thus this is pronounced "light-d" or "lighty".

  • Founded in 2003
  • Open Source
  • On-the-fly output compression
  • web hosting software that focuses on scalability and performance

More about this project's history can be found here.


Introduction

This tutorial will cover the installation and configuration of MediaWiki with the Lighttpd web server on Ubuntu 14.04.

Note: There is an outdated version of MediaWiki is available through Ubuntu's  
      repository however we will install the latest stable version with git.

Prerequisites

  • Super User access

  • MySQL is installed 

    MySQL Installation:

    Run the following commands as a super user.

    sudo apt-get install mysql-server
    

    MySQL Security Configuration (recommended):

    Answer yes to the following prompts unless otherwise desired. Ensure that this password is saved as it will be vital for later operations:

    sudo /usr/bin/mysql_secure_installation
    

    Ensure that MySQL is protected by a password.

  • PHP is installed: 

    PHP Installation:

    The following PHP packages will need to be installed:

    sudo apt-get install php5 php5-fpm php5-mysql php5-cgi php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
    

    ```

    Ensure that all packages have installed correctly before proceeding.

    PHP Configuration:

    Edit /etc/php5/fpm/php.ini:

    sudo vim /etc/php5/fpm/php.ini
    

    Uncomment the following line in /etc/php5/fpm/php.ini by removing the semicolon ; (approx. line 768)

    cgi.fix_pathinfo=1
    

Download and Initial installation

MediaWiki

Installation via most current tar-ball:

  1. First we will need to determine the version that is desired to be installed. Available versions can easily be determined via the cURL command (and a sed statement to remove HTML tags if desired):

    curl -s https://releases.wikimedia.org/mediawiki/ | sed 's/<[^>]*>//g'
    

    Example output:

    root@Writing-Demo:~# curl -s https://releases.wikimedia.org/mediawiki/ | sed 's/<[^>]*>//g'
    
    
    MediaWiki Releases
    
    
    MediaWiki Releases
    
    
    Name                    Last modified      Size  Description Parent Directory                             -
    snapshot/               2009-07-18 00:03    -
    1.26/                   2016-05-20 17:01    -
    1.25/                   2016-05-20 17:01    -
    1.24/                   2016-03-31 20:46    -
    1.23/                   2016-05-20 17:00    -
    1.22/                   2014-12-17 20:29    -
    1.21/                   2014-06-25 21:56    -
    1.20/                   2013-11-14 23:21    -
    1.19/                   2015-03-31 20:27    -
    1.18/                   2012-11-30 00:26    -
    1.17/                   2012-06-13 21:11    -
    1.16/                   2011-05-05 05:50    -
    1.15/                   2010-07-28 07:43    -
    1.14/                   2009-07-20 06:17    -
    1.13/                   2009-07-20 06:17    -
    1.12/                   2009-07-20 06:17    -
    1.11/                   2009-07-19 17:37    -
    1.10/                   2009-07-19 17:39    -
    1.9/                    2009-07-19 17:19    -
    1.8/                    2009-07-19 17:20    -
    1.7/                    2009-07-19 17:21    -
    1.6/                    2009-07-19 17:23    -
    1.5/                    2009-07-19 17:26    -
    1.4/                    2009-07-19 17:28    -
    1.3/                    2009-07-19 17:30    -
    
    
    Apache Server at releases.wikimedia.org Port 80
    
    
    root@Writing-Demo:~#
    

    Once you have decided the version that you would like to download you can curl that version number's directory like so:

    root@Writing-Demo:~# curl -s https://releases.wikimedia.org/mediawiki/1.26/ | sed 's/<[^>]*>//g'
    
    
    Index of /mediawiki/1.26
    
    
    Index of /mediawiki/1.26
    Name                             Last modified      Size  Description Parent Directory                                      -
    mediawiki-i18n-1.26.2.patch.gz   2015-12-21 01:14   20
    mediawiki-i18n-1.26.1.patch.gz   2015-12-18 00:21   20
    mediawiki-core-1.26.3.tar.gz.sig 2016-05-20 22:18  287
    mediawiki-core-1.26.3.tar.gz     2016-05-20 22:18   21M
    mediawiki-core-1.26.2.tar.gz.sig 2015-12-21 01:14  287
    mediawiki-core-1.26.2.tar.gz     2015-12-21 01:14   21M
    mediawiki-core-1.26.1.tar.gz.sig 2015-12-18 00:21  287
    mediawiki-core-1.26.1.tar.gz     2015-12-18 00:21   21M
    mediawiki-core-1.26.0.tar.gz.sig 2015-11-25 19:54  287
    mediawiki-core-1.26.0.tar.gz     2015-11-25 19:54   21M
    mediawiki-1.26.3.tar.gz.sig      2016-05-20 22:18  287
    mediawiki-1.26.3.tar.gz          2016-05-20 22:18   24M   # Latest version listed here
    mediawiki-1.26.3.patch.gz.sig    2016-05-20 22:18  287
    mediawiki-1.26.3.patch.gz        2016-05-20 22:18   11K
    mediawiki-1.26.2.tar.gz.sig      2015-12-21 01:13  287
    mediawiki-1.26.2.tar.gz          2015-12-21 01:13   24M
    mediawiki-1.26.2.patch.gz.sig    2015-12-21 01:13  287
    mediawiki-1.26.2.patch.gz        2015-12-21 01:13  1.0K
    mediawiki-1.26.2.gz.sig          2015-12-21 01:13  287
    mediawiki-1.26.1.tar.gz.sig      2015-12-18 00:21  287
    mediawiki-1.26.1.tar.gz          2015-12-18 00:21   24M
    mediawiki-1.26.1.patch.gz.sig    2015-12-18 00:20  287
    mediawiki-1.26.1.patch.gz        2015-12-18 00:20  7.5K
    mediawiki-1.26.0.tar.gz.sig      2015-11-25 19:54  287
    mediawiki-1.26.0.tar.gz          2015-11-25 19:54   24M
    

    Apache Server at releases.wikimedia.org Port 80

    root@Writing-Demo:~#

    Note: At the time of making this version 1.26 was available as of 2016-05-20 17:01 and the latest tar-ball available was mediawiki-1.26.3.tar.gz modified at 2016-05-20 22:18

    Later versions may be available and you should adjust later commands to account for newer versions if desired.

  2. We will now need to download this latest version utilizing curl or wget:

    curl -o mediawiki-core-1.26.3.tar.gz https://releases.wikimedia.org/mediawiki/1.26/mediawiki-core-1.26.3.tar.gz
    

    -- OR --

    wget https://releases.wikimedia.org/mediawiki/1.26/mediawiki-core-1.26.3.tar.gz
    
  3. Extract the tar-ball: 

    tar -xzvf mediawiki-core-1.26.3.tar.gz
    
  4. Move the extracted directory to a location under /var/www that will make sense for what you future intentions. If you are unsure about this location b. will work for you

    • /var/www/html/example.com/mediawiki-1.26.3
    • /var/www/mediawiki-1.26.3

      mv mediawiki-1.26.3/ /var/www/mediawiki-1.26.3/
      

Lighttpd

This can be installed via Digital Ocean's Repositories:

sudo apt-get install Lighttpd

Software Configuration:

MySQL:

You will need to configure a database for your as well as a user in for MediaWiki

  1. Log into MySQL: 

    mysql -u root -p
    

    You should now note that you are in the MySQL shell after entering your password. 

    MySQL shell has a different prompt defined by `mysql>`
    
  2. Verify current version matches a supported version as listed here

    status
    
  3. Create database: 

    create database mediawiki;
    
  4. Create a user, and grant that user permissions: 

    GRANT index, create, select, insert, update, delete, alter, lock tables on mediawiki.* TO mediawikiuser@localhost IDENTIFIED BY 'RAND_PASS';
    

    You will need to make not of this password for later use.

  5. Flush privileges (this will force a reload allowing MySQL to realize that there is a new user): 

    flush privileges;
    
  6. Exit the MySQL shell: 

    \q
    ## OR ##
    exit
    

Lighttpd:

This will require two extensions enabled:

sudo lighttpd-enable-mod fastcgi fastcgi-php

After this is completed restart the service:

sudo service lighttpd restart

vHost configuration may be performed at this time if desired. This tutorial will not cover this.

MediaWiki:

In a new tab in your web browser navigate to your Server's IP address.  

Example: http://123.45.67.89/mediawiki-1.26.3/mw-config/

Where:  
          http://123.45.67.89/mediawiki-1.26.3/mw-config/
 Is your Server IP ---^      |         ^-- is a directory with a path under:
                                            /var/www/mediawiki-1.26.3/mw-config/

At this point you should be prompted with a "MediaWiki 1.26.3 installation" Installation page.


Brief troubleshooting steps that can be taken

If you are seeing an error page ensure that you have:

  • restarted Lighttpd after enabling plugins (This would actually probably propogate as a 403)
  • moved the directory correctly
    • This can be confirmed by ls -la /var/www

Upon opening this page you will note that the the page seems to have a CSS error. This is to be expected since 'skins' are not not loaded by default in latest available versions.

Web configuration of MediaWiki

  1. You will need to select the language that you would like to have configured. Click Continue when ready to proceed.

  2. Environment check should show your current configuration and you will probably see a warning that is similar to the following that can be ignored. As before click Continue when ready to proceed.

    • Warning: Could not find APC, XCache or WinCache.
  3. On the Connect to database page you will need to select the settings for your database. The following fields should have the following data:

    • Database host:

      • localhost
    • Database name:

      • mediawiki
    • Database table prefix:

      • [THIS CAN BE LEFT BLANK]
    • Database username:

      • mediawikiuser
    • Database password:

      • [RAND_PASS that was generated earlier]
    • Click Continue after this data is entered.

    • MySQL password may need to be changed if it is too complex and has a single quote in it.

  4. On the Database settings page you will need to select the following:

    • Database account for web access

      • Left checked in the tutorial
    • Storage engine:

      • InnoDB
    • Database character set:

      • Binary
    • Click Continue after these settings are selected.

  5. On the Name page you can select the name of your wiki. As well as setup the username and password of your user. Note that email is not required.

    • Select the I'm bored already, just install the wiki. bubble after you have set the desired name and user, and click Continue. This will skip the options page.
  6. On the Install page you will be prompted with before installing the wiki click Continue when ready.

    • When all tasks are 'done' click Continue again
  7. At this point your browser will automatically download LocalSettings.php. This file will need to be copied to your server before proceeding, and placed in the mediawiki-1.26.3 folder.

    • This can be easily achieved with the scp command from your client device if you are on a client that has a bash shell.

      scp -P 22 ~/Downloads/LocalSettings.php username@123.45.67.89:/var/www/mediawiki-1.26.3/
      # 22 specifies the port number if you are using non-statdard ports.
      # again 123.45.67.89 is replaced by your servers IP
      

      Once this has been completed you can click the enter your wiki

  8. You will note that you do not have any skins enabled. This can easily be corrected by:

    • Downloading a skin (in this instance Blueprint is downloaded):

      curl -o /var/www/mediawiki-1.26.3/skins/Blueprint-REL1_26-61c6768.tar.gz https://extdist.wmflabs.org/dist/skins/Blueprint-REL1_26-61c6768.tar.gz
      

      Additional skins can be found here.

    • Extracting the skin

      tar -xzf /var/www/mediawiki-1.26.3/skins/Blueprint-REL1_26-61c6768.tar.gz
      
    • Editing your LocalSettings.php file to include the following on the last line:

      wfLoadSkin( 'Blueprint' );
      

Congratulations you have just configured your first Wiki!

You can read more about FAQ here and find additional user support here.