Skip to content

Instantly share code, notes, and snippets.

@chrisdchristo
Created December 28, 2013 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdchristo/8159924 to your computer and use it in GitHub Desktop.
Save chrisdchristo/8159924 to your computer and use it in GitHub Desktop.
101: MediaWiki

101: MediaWiki

Install the package:

sudo apt-get install mediawiki

By default, an apache mediawiki.conf file is placed in /etc/apache2/conf.d/mediawiki.conf which links a conf file in the mediawiki installation. Its is better to manage the various websites via ssl encrypted virtual hosts.

sudo mv /etc/apache2/conf.d/media.conf /etc/apache2/sites-available/mediawiki
sudo nano /etc/apache2/sites-available/mediawiki
<VirtualHost *:444>
Alias /wiki /var/lib/mediawiki
DocumentRoot /var/lib/mediawiki

<Directory /var/lib/mediawiki/>
	Options +FollowSymLinks
	AllowOverride All
	order allow,deny
	allow from all
</Directory>

# some directories must be protected
<Directory /var/lib/mediawiki/config>
	Options -FollowSymLinks
	AllowOverride None
</Directory>
<Directory /var/lib/mediawiki/upload>
	Options -FollowSymLinks
	AllowOverride None
</Directory>
SSLEngine on
SSLCACertificateFile /etc/ssl/custom/certs/official-www-mydomain-com-ad-inter.crt
SSLCertificateFile    /etc/ssl/custom/certs/official-www-mydomain-com.crt
SSLCertificateKeyFile /etc/ssl/custom/keys/official-www-mydomain-com.key
</VirtualHost>

First you'll need to get apache to listen to port 444 under SSL. Open the ports config file:

sudo nano /etc/apache2/ports.conf

and add the lines Listen 444 to both the mod_ssl and mod_gnutls modules.

<IfModule mod_ssl.c>
   ...
    Listen 444
</IfModule>

<IfModule mod_gnutls.c>
    ...
    Listen 444
</IfModule>

If you want remote access make sure you open the port 444 on your firewall. You then want to enable the website and restart the web server:

sudo a2ensite mediawiki
sudo /etc/init.d/apache2 restart

Finally, wiki can be accessed by the following:

https://mydomain.com:444/wiki

After you go through the instructions on setting up the wiki, it will ask you to download the LocalSettings.php file. Do so, then copy it to /etc/mediawiki/.

sudo cp LocalSettings.php /etc/mediawiki/LocalSettings.php

Then do some cleanup:

sudo chown www-data /etc/mediawiki/LocalSettings.php
sudo chmod 600 /etc/mediawiki/LocalSettings.php
sudo rm -Rf /var/lib/mediawiki/config

MediaWiki LDAP

First you need to add a wiki user that also exists on the ldap server users. Use the same username and password for both. Add the user to the bureaucrat and administrator groups. In the wiki add user1 via the Special Pages and assign him to both groups.

sudo ldapadduser user1 wiki
sudo ldapsetpasswd user1
enter the same password

Next you need to download the mediawiki ldap plugin:

http://www.mediawiki.org/wiki/Extension:LDAP_Authentication#Current_version

Untar and move the contents of the folder to /var/lib/mediawiki/extensions/LdapAuthentication.

There might be an sql file which you will need to execute on your wiki database.

Next we need include in our LocalSettings.php file:

sudo nano /var/lib/mediawiki/LocalSetting.php

add the following lines at the end:

# LDAP
require_once( "$IP/extensions/LdapAuthentication/LdapAuthentication.php" );
$wgAuth ## new LdapAuthenticationPlugin();
$wgLDAPDomainNames ## array( "n1" );
$wgLDAPServerNames ## array( "n1" ##> "n1.mydomain.com" );
$wgLDAPSearchStrings ## array( "n1" ##> "uid##USER-NAME,ou##users,dc##mydomain,dc##com" );
$wgLDAPEncryptionType ## array( "n1" ##> "clear" );

Leave USER-NAME as it is, do not modify it.

MediaWiki LDAP SSL

http://ryandlane.com/blog/2009/06/16/using-the-ldap-authentication-plugin-for-mediawiki-the-basics-part-2/

Alter the following line:

$wgLDAPEncryptionType ## array( "n1" ##> "tls" );

Logo

To change the icon make a 135x135 pixel logo in PNG format and move it to the right place:

sudo cp logo.png /var/lib/mediawiki/skins/common/images/logo.png

Edit the LocalSettings.php file by setting the location of the logo.

Open the file:

sudo nano /etc/mediawiki/LocalSettings.php

Replace this line:

$wgLogo ## "$wgStylePath/common/images/logo.png";

External Links Open New Window

Links by default open in the same window which can be irritating. Open up the LocalSettings.php file:

sudo nano /var/lib/mediawiki/LocalSettings.php

and add the following line at the bottom:

$wgExternalLinkTarget ## '_blank';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment