Tune up Mediawiki v1.21 Installation for a Personal Usage

As the topic implies, we’ll be tuning up a default Mediawiki v1.21 installation for a personal usage.

1.21.5 is the latest stable legacy version of the Mediawiki 1.21.x family and will be discontinued in May 2014. This version should be replaced with a future version of Mediawiki 1.23.x (LTS), which is due to be released in May 2014.

Make Mediawiki Private

All lines have to be added at the bottom of the LocalSettings.php file.

Disable Public Read and Edit

$wgGroupPermissions['*']['read'] = false;
$wgGroupPermissions['*']['edit'] = false;

Disable User Edit

$wgGroupPermissions['user']['edit'] = false;

Disable Account Creation

$wgGroupPermissions['*']['createaccount'] = false;

Only Allow Admins to Edit

$wgGroupPermissions['sysop']['edit'] = true;

Remove “Log in” and “Create Account” Links

Add the following lines at the end of the LocalSettings.php file:

#Removes login and create account links
$wgHooks['PersonalUrls'][] = 'lfRemoveLoginLink';
function lfRemoveLoginLink( &$personal_urls, $title ) {
       unset( $personal_urls['login'] );
       unset( $personal_urls['anonlogin'] );
       unset( $personal_urls['createaccount'] );
       return true;
}

Remove “My Talk”

Open /var/www/<wiki_name>/includes/SkinTemplate.php and comment out the following lines:

/*
 $personal_urls['mytalk'] = array(
 'text' => $this->msg( 'mytalk' )->text(),
 'href' => &$usertalkUrlDetails['href'],
 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
 );
 */

Remove Footer Links

This can remove About, Privacy Policy and Disclaimer footer links.

Open the MediaWiki:Common.css page and add the following:

#footer-places-privacy { display:none;}
#footer-places-disclaimer { display:none;}
#footer-places-about { display:none;}

You may need to restart your browser to notice changes.

Don’t Show IP Inside Header

Add the following line at the end of the LocalSettings.php file:

$wgShowIPinHeader = false;

Change Logo Image

Open the LocalSettings.php file and change the following line to point to your image:

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

Make sure your new logo is placed inside the images directory. Full path (on Debian) should read as:

/var/www/<wiki_name>/skins/common/images/YOUR_LOGO_NAME.png

Add Favicon Icon

Add the following line at the end of the LocalSettings.php file:

$wgFavicon = "$wgScriptPath/favicon.ico";

Ensure you have a favicon.ico file placed inside the Mediawiki’s root directory.

Add Allowed File Types For Uploads

Modify the following line appropriatelly in the LocalSettings.php file:

$wgFileExtensions = array('png','pdf','py','zip','tgz','xml');

Make sure file uploads are enabled on php (normally /etc/php5/apache2/php.ini):

file_uploads = On

as well as on Mediawiki (LocalSettings.php) and that you have an “uploadaccess” group for that:

$wgEnableUploads = true;
$wgGroupPermissions['uploadaccess']['upload'] = true;

Configure Shared Memory to Make Mediawiki Faster

Add the following lines to the LocalSettings.php file (you should be able to figure out the exact place in the file):

# Shared memory settings
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = array();
$wgMessageCacheType = CACHE_ACCEL;
$wgUseLocalMessageCache = true;
$wgParserCacheType = CACHE_ACCEL;
$wgUseGzip = true;
#$wgEnableSidebarCache = true;
$wgUseFileCache = true;
$wgFileCacheDirectory = "{$wgCacheDirectory}/html";

Configure Email Settings

Assuming you have mail and net_smtp packages installed already:

# apt-get install php-pear
# pear install mail  
# pear install net_smtp

Add the following lines to the LocalSettings.php file:

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgPasswordReminderResendTime = 1;

$wgSMTP = array(
	"host" => 'ssl://mail.example.com', 
	"IDHost" => 'example.com', 
	"port" => "465",
	"auth" => true,
	"username" => 'user',
	"password" => 'passwd'
);

$wgEmergencyContact = "[email protected]";
$wgPasswordSender = "[email protected]";

$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;

Customise the Default Login Page

Open the MediaWiki:Loginreqpagetext page and modify as you need.

Lock Database for Upgrades

If at some point you need to upgrade the wiki, read only access may become quite handy. Add these lines at the end of the LocalSettings.php file:

#Lock the database
$wgReadOnly = 'Down for maintenance, access will be restored shortly';

Don’t forget to remove the lines after the upgrade.

Magic Words

I found some of those magic words very useful, for example, this wiki line below:

There are currently {{NUMBEROFPAGES}} wiki pages created and {{NUMBEROFFILES}} files uploaded.

Appears as follows:

There are currently 315 wiki pages created and 61 files uploaded.

Check magic words’ reference here: https://www.mediawiki.org/wiki/Help:Magic_words

Related Posts

Upgrade from Mediawiki v1.21 to Mediawiki v1.23.0 on Debian Wheezy