MediaWiki on Ubuntu

From GridTrak

Jump to: navigation, search

You are looking at Medial Wiki 1.16.5 on Ubuntu Server 10.0.4 right now B-)
Updated May 26, 2011 ajs

Contents

Infrastructure Preparation

  • Do this before setting up the USWIKI server. This can be done after server setup; but I found it easier to do it before.
->  Configure your DHCP Reservation for you server's network adapter's MAC address and IP Address
    This will allow the server setup to assign a predictable DHCP IP address.
 or
    Configure the USWIKI server for a static IP address:  /etc/network/interfaces 
    For example:
      # Local network interface
      auto eth0
      iface eth0 inet static
      address 192.168.0.254
      netmask 255.255.255.0
      network 192.168.0.0
      broadcast 192.168.0.255
      gateway 192.168.0.1
      dns-nameservers 192.168.0.85

->  Configure your LAN DNS with an "A HOST" record for the server's name and LAN IP address.
->  Configure your WAN DNS with an "A HOST" record for the server's name and WAN IP address.
->  Configure your Firewall/Router appropriately
    Note:  You may want to block WAN access to the server until it is ready for production.
->  [optional] Add PuTTY to a remote system for remote access to the new system.

Ubuntu Server 10.0.4 Setup

1. Install Ubuntu Server with LAMP (Linux Apache MySQL PHP) and OpenSSH options

 sudo tasksel
 * LAMP: will prompt for the MySQL root password.  Remember this password!
 * OpenSSH
 sudo reboot now

2. Run the following to update the system and install Lynx text browser

 sudo aptitude update  
 sudo aptitude upgrade
 sudo reboot now

MediaWiki Setup

3. Download [1] and save a copy to the server's /var/www directory

 cd /var/www
 sudo wget http://download.wikimedia.org/mediawiki/1.16/mediawiki-1.16.5.tar.gz

4. Extract the MediaWiki software

 sudo tar xvzf mediawiki-*.tar.gz

5. Rename the newly created subdirectory to "wiki" and cd to it

 sudo mv mediawiki-1.16.5 wiki
 cd wiki
 chmod a+w config

5. On a different computer (because Ubuntu Server is non-GUI), use the web browser to access the Wiki final installation procedure.

For example, if the server's name (DNS A record) is "uswiki" in the DNS domain "penguinfood.net", then point a browser to http://uswiki.penguinfood.net/wiki

 In the setup's database options, select to use the MySQL root account and password 

6. On the USWIKI server, move the LocalSettings.php file to the /var/www/wiki folder (parent of the wiki/config folder).

 /var/www/wiki$ sudo mv config/LocalSettings.php .

7. Remove the wiki/config folder

 /var/www/wiki$ sudo rm -rf config

7.a. Protect the LocalSettings.php file

 /var/www/wiki$ sudo chmod 600 LocalSettings.php

MediaWiki Configuration Changes

MediaWiki Configuration Changs

Updated Feb 5, 2010 ajs

8.a. Craete a folder for mysitestuff; then put logos and other stuff there.

8.b. Edit LocalSettings.php, add the following:

 $wgLogo = "/wiki/mysitestuff/mysitelogo.png";
 
 # Note:  The default MediaWiki permissions allow for anonymous account creation.
 #        This allows vandals to destroy the wiki.  
 #        For more secure settings, copy and modify the defaults.
 # See Restricting Account Creation
 # and User Rights
 # The following permissions require the sysop to Create Accounts for users.
 # These disable anonymous creativity but allow users registetered by the sysop typical wiki rights.
 $wgEmailConfirmToEdit = true;
 # Implicit group for all visitors
 $wgGroupPermissions['*']['createaccount']    = false;
 $wgGroupPermissions['*']['read']             = true;
 $wgGroupPermissions['*']['edit']             = false;
 $wgGroupPermissions['*']['createpage']       = false;
 $wgGroupPermissions['*']['createtalk']       = false;
 $wgGroupPermissions['*']['writeapi']         = false;
 $wgEnableUploads = true;
 $wgFileExtensions = array('png', 'jpg', 'jpeg', 'mp3', 'mov', 'pdf', 'svg', 'htm', 
   'html', 'gif', 'doc', 'docx', 'pdf', 'zip', 'odt', 'ods', 'xls', 'xml', 
   'dwg', 'dxf', '7z', 'gz', 'tar', 'rar');
 
 # Turn off Verify Mime Type if 'zip' files are to be allowed - Mime Type Detection
 $wgVerifyMimeType = false;

8.c. Secure the LocalSettings.php file

 sudo chmod 600 LocalSettings.php

8.d. Increase maximum file size and php memory

 php -i
 # Note:  If no php, then
 sudo apt-get install php5-cli
 sudo nano /etc/php5/apache2/php.ini
 sudo nano /etc/php5/cli/php.ini
 -> upload_max_filesize = 200M
 -> post_max_size = 200M
 -> memory_limit = 128M
 -> max_execution_time = 120

9. Set security permissions on the /var/www/wiki/images/ folders

 sudo chmod a+w --recursive /var/www/wiki/images/

EMail Setup

10. Install the php cli and pear

 sudo apt-get install php5-cli
 sudo apt-get install php-pear

For more information on pear see the PEAR Manual

pear diagnostics: Create a /var/www/check_pear.php and view it in a browser.

 <?php phpinfo(); ?>
 <?php
 require_once 'System.php';
 var_dump(class_exists('System'));
 ?> 

11. SMTP Configuration

 sudo pear install MAIL
 sudo pear install Net_SMTP

11.a. LocalSettings.php

 $wgSMTP = array(
 'host' => "ssl://smtp.gmail.com",
 'IDHost' => "gmail.com",
 'port' => 465,
 'auth' => true,
 'username' => "youremail@gmail.com",
 'password' => "yourpassword"
 );

12. Restart Apache2

 sudo apache2ctl restart

Enable Imagemagick and Thumbnails

The |thumb option added to an image: tag will automatically generate a thumbnail version of a picture - if support has been enabled, as follows:

  • The ImageMagick package must be installed:
sudo aptitude install imagemagick
  • In LocalSettings.php, make sure the following settings are in place and not commented out. They are normally about 80 lines down in the file marked "To enable image uploads":
 $wgUseImageResize = true;
 $wgUseImageMagick = true;
 $wgImageMagickConvertCommand = "/usr/bin/convert";

Adding a Meta Tag for Google Webmaster Verification

 sudo nano /var/www/wiki/includes/OutputPage.php
 [^W Where Is] Search: addDefaultMeta
  • Add a Meta Tag for Google WebMaster Verification using $this->addMeta()
 $this->addMeta( 'verify-v1', 'Cncfp+ykoVA2VdMFwA+srUZdlgxZtV80Bt1oFiMUNRU=' );
  • The result will look something like this:
  <html ...>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta name="generator" content="MediaWiki 1.15.1" />
      <meta name="verify-v1" content="Cncfp+ykoVA2VdMFwA+srUZdlgxZtV80Bt1oFiMUNRU=" />
      ...
    </head>
    <body ...>

Wiki Backup and Restore Procedures

About the Author - Arnold

The author is still a Linux novice and needs to put this article here so he can rebuild his own wiki.

Personal tools