NOTICE: This wiki will be RETIRED after 01/01/2012. If you want to preserve articles, please contact the wiki administrator.
MediaWiki on Ubuntu Server
From Johns Hopkins Linux Users Group
Updated Aug 2, 2011 ajs
Contents |
Infrastructure Preparation
- Do this before setting up the US904 server. This could 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 US904 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 9.0.4 Setup
Updated Feb 5, 2010 ajs
- Note: This procedure also works with Ubunutu Server 9.10
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 apt-get update sudo apt-get install lynx sudo apt-get dist-upgrade sudo apt-get autoclean sudo reboot now
MediaWiki Setup
3. Download MediaWiki 1.15.1 and save a copy to the server's /var/www directory
cd /var/www sudo wget http://download.wikimedia.org/mediawiki/1.15/mediawiki-1.15.1.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.15.1 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 "us904" in the DNS domain "penguinfood.net", then point a browser to http://us9040.penguinfood.net/wiki
In the setup's database options, select to use the MySQL root account and password
6. On the US904 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
MediaWiki Configuration Changes
Updated Aug 2, 2011 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;
# Set Permissions for All Visitors
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = false;
$wgGroupPermissions['*']['createtalk'] = false;
# Set Permissions for Logged In Users
$wgGroupPermissions['user']['edit'] = true;
$wgGroupPermissions['user']['createpage'] = true;
$wgGroupPermissions['user']['createtalk'] = true;
$wgEnableUploads = true;
$wgFileExtensions = array_merge($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', 'exe'));
# Turn off Mime Type Verification if you want to be able to handle 'zip' files
$wgVerifyMimeType = false;
# Enable 'exe' files to be uploaded by removing them from the File Blacklist
# This override is not a good idea for public wiki sites!
# I include it here because I use it for my private wikis.
@wgFileBlacklist = array_diff( $wgFileBlacklist, array('exe') );
# Mime Type Detection
# Configuring File Types
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 = 32M -> 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'));
?>
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
- MediaWiki Help Reference
- Edit the OutputPage.php file addDefaultMeta function
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.