The instructions show how to setup a server to host any number of separate MediaWiki wikis on a server installed according to Base Installation of a CentOS Server.
The resulting system will have the following properties.
Install CentOS according to Base Installation of a CentOS Server.
Edit /root/netfilter.sh to enable TCP connections to port 80. To do this, add the following line after the similar one for port 22.
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Then, run the following to make changes current and persistent.
/root/netfilter.sh
The following command installs mysql server, apache web server and php. Because Mediawiki requires php version 5.0 or later, we install these packages from the centosplus repository.
yum --enablerepo=centosplus install php.i386 php-mysql.i386 mysql-server.i386 mod_ssl.i386
Configure the mysql server to run when the system initializes, and set the mysql root password to root.
chkconfig mysqld on service mysqld start mysqladmin password root
Configure web server to run when the system initializes.
chkconfig httpd on
yum install ImageMagick-devel.i386
Install packages needed to compile Objective Caml from source.
yum install compat-gcc-32-c++.i386 libtool.i386 gcc-c++.i386
Install Objective Caml. As a non-root user, do the following.
wget http://caml.inria.fr/pub/distrib/ocaml-3.10/ocaml-3.10.0.tar.gz tar -zxvf ocaml-3.10.0.tar.gz cd ocaml-3.10.0/ ./configure make world make opt sudo make install make clean
Install latex and other needed packages.
yum install tetex-latex.i386 ghostscript.i386 gd-devel.i386
Install libevent, because it is a prerequisite for memcached.
wget http://monkey.org/~provos/libevent-1.3c.tar.gz tar -zxvf libevent-1.3c.tar.gz cd libevent-1.3c/ ./configure --prefix=/usr make sudo make install
Install memcached, because we will configure mediawiki to use this for caching.
#wget http://www.danga.com/memcached/dist/memcached-1.2.1.tar.gz wget http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz tar -zxvf memcached-1.2.2.tar.gz cd memcached-1.2.2 ./configure --prefix=/usr make sudo make install
Start the memcached daemon when the system initializes. To do this, add the following line to /etc/rc.local. (Change turner to a valid username.)
memcached -u turner -d -m 1024 -l 127.0.0.1 -p 11211
The above command tells memcached to run under user account turner, run as a daemon, use 1024 MB of memory (1 GB), and listen on port 11211 of the localhost network interface. Change the amount of memory to an amount that makes sense for your system.
If you don't plan on rebooting soon, you should manually run the above command to start memcached.
In this section, we setup a wiki that users access through /sysadmin.
Get and extract the most recent stable release of mediawiki.
mkdir /var/www/wikis cd /var/www/wikis wget http://download.wikimedia.org/mediawiki/1.10/mediawiki-1.10.1.tar.gz tar -zxvf mediawiki-1.10.1.tar.gz mv mediawiki-1.10.1 sysadmin
Compile math support.
cd /var/www/wikis/sysadmin/math make
Make apache owner of files.
chown -R apache:apache /var/www/wikis/sysadmin
Create /etc/httpd/conf.d/sysadmin.conf with the following contents. The rewrite rules given below remove the /index.php from the urls.
Alias /sysadmin /var/www/wikis/sysadmin <Directory "/var/www/wikis/sysadmin"> DirectoryIndex index.php index.html </Directory>
Start (or resart) web server.
service httpd start
Start web-based configuration by going to http://localhost/sysadmin in a browser, where host is the hostname on which your system is running. Select memcached shared memory caching, and in the memcached servers text box, specify the following.
localhost:11211
Select the checkbox to use superuser account, and fill out mysql superuser name and password (root and root).
Complete other the configuration fields as required, and click button to install.
Move the LocalSettings.php file from the config subdirectory into the root directory of the mediawiki folder, and delete the config subdirectory.
cd /var/www/wikis/sysadmin mv config/LocalSettings.php . rm -rf config
Add the following lines to the bottom of LocalSettings.php (before the terminating ?> in the file). Several of these settings overwrite values set in earlier parts of the file.
$wgArticlePath = "{$wgScriptPath}/$1";
$wgUseTeX = true;
$wgUseMemCached = true;
$wgMemCachedServers = array( "127.0.0.1:11211" );
$wgEnableUploads = true;
$wgAllowExternalImages = true;
$wgFileExtensions[] = 'pdf';
# Disable new registrations from anonymous users.
$wgGroupPermissions['*']['createaccount'] = false;
# Disable anonymous edits.
$wgGroupPermissions['*']['edit'] = false;
Replace the contents of /etc/httpd/conf.d/sysadmin.conf with the following.
Alias /sysadmin /var/www/wikis/sysadmin
<Directory "/var/www/wikis/sysadmin">
DirectoryIndex index.php index.html
</Directory>
RewriteEngine On
RewriteRule ^/sysadmin/Skins/(.*)$ /sysadmin/skins/$1 [PT]
RewriteCond $1 !skins/
RewriteCond $1 !images/
RewriteCond $1 !Skins/
RewriteCond $1 !index.php
RewriteCond /var/www/wikis/sysadmin/%{REQUEST_FILENAME} !-f
RewriteCond /var/www/wikis/sysadmin/%{REQUEST_FILENAME} !-d
RewriteRule ^/sysadmin/(.*) /sysadmin/index.php/$1 [PT,L,QSA]
PNG files do not upload correctly. See [1] for an explanation. To fix this problem, add the following line to '/etc/httpd/conf/magic'.
0 string \211PNG image/png
Restart the web server, so that it reads the changes to the configuration file.
service httpd restart
I had a lot of problems when making changes to LocalSettings.php, because of mediawiki caching activity. When I turned off all caching, I no longer had these problems. If you want to experiment with making changes to LocalSettings.php, then you can turn off caching by inserting the following lines in LocalSettings.php. (Source)
# Disable all forms of MediaWiki caching $wgMainCacheType = CACHE_NONE; $wgMessageCacheType = CACHE_NONE; $wgParserCacheType = CACHE_NONE; $wgCachePages = false;
Add the following lines to the <VirtualHost _default_:443> section of /etc/httpd/conf.d/ssl.conf.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !Special:Userlogin
RewriteCond %{QUERY_STRING} !Special:Userlogin
RewriteRule ^(.*)$ http://wiki.csci.csusb.edu$1 [R]
RewriteRule ^(.*)/Special:Userlogin$ $1/index.php/Special:Userlogin [PT,L,QSA]
Add the following to /etc/httpd/conf.d/wikis.conf after the RewriteEngine On and before the first RewriteRule.
RewriteCond %{REQUEST_FILENAME}%{QUERY_STRING} Special:Userlogin
RewriteRule ^(.*)$ https://wiki.csci.csusb.edu$1 [R]
The following instructions were derived from How do I create a real SSL Certificate? If you will not use a certificate signed by a certificate authority, then skip the following steps.
Generate a private key.
openssl genrsa -out server.key 1024
Generate a certificate signing request. (Enter "." to make an entry blank.)
openssl req -new -key server.key -out server.csr
Examine your csr.
openssl req -noout -text -in server.csr
Send the csr file to the certificate authority (CA). After the CA returns your signed certificate (server.crt), examine it with the following command.
openssl x509 -noout -text -in server.crt
Store copies of server.key and server.crt is a secure off-line medium (CD) and look up. Move files into their permanent locations (overwriting the old files).
mv server.key /etc/httpd/conf/ssl.key/ mv server.crt /etc/httpd/conf/ssl.crt/
Get the server certificate chain and store it in the following file:
/etc/httpd/conf/ssl.crt/ca.crt
Uncomment the following line in /etc/httpd/conf.d/ssl.conf.
SSLCertificateChainFile /etc/httpd/conf/ssl.crt/ca.crt
Restart apache.
service httpd restart
In order to make the site look less like a public wiki, and more like an official website, we removed the tabs and section edit links by doing the following.
Include the following in LocalSettings.php.
$wgDefaultUserOptions['editsection'] = 0;
In skins/MonoBook.php, replace the following line
foreach($this->data['content_actions'] as $key => $tab)
with the following:
if($this->data['loggedin'] == 1) foreach($this->data['content_actions'] as $key => $tab)
To modify the menu of links appearing in the sidebar, I edited MediaWiki:Sidebar.
To remove the toolbox for non-logged in users, see How do I remove the toolbox for users that are not logged in?
To make the site accessible, I added a tools section to the sidebar with links to Word Reader and Adobe Reader. I also included a skip navigation link as follows.
I created a skip-navigation link by modifying skins/MonoBook.php. Add the following somewhere just after the body element.
<a href="#ContentArea"><img src="/images/spacer.gif" alt="Skip to main content" width="1" height="1"></a>
Just before the menu section, add the following.
<a name="ContentArea"></a>
To enable easy maintenance of a global style rules through the wiki interface itself, do the following.
Include the following in LocalSettings.php.
$wgUseSiteCss = true;
Add the following link to the Help page.
[[MediaWiki:Common.css]]
Add style rules to the above page. For example, I added the following style rules (taken from mediawiki documentation).
/***** Table formatting *****/
table.wikitable,
table.prettytable
{
margin:1em 1em 1em 0;
background:#F9F9F9;
border:1px #AAA solid;
border-collapse:collapse;
}
table.wikitable th,
table.wikitable td,
table.prettytable th,
table.prettytable td
{
border:1px #AAA solid;
padding:0.2em;
}
table.wikitable th,
table.prettytable th
{
background:#F2F2F2;
text-align:center;
}
table.wikitable caption,
table.prettytable caption
{
margin-left:inherit;
margin-right:inherit;
}
Now, you can create nicely formatted tables as in the following example.
{| class="wikitable"
|+ Caption
! Header
|-
| Content
|}
If you want to setup a wiki behind a proxy, then you can try to follow the notes in this section.
This section assumes that the public-facing proxy server is csci.csusb.edu, and the wiki server is web9.ias.csusb.edu.
On the public-facing proxy machine, create /etc/httpd/conf.d/sysadmin.conf with the following contents.
RewriteRule ^/sysadmin$ http://csci.csusb.edu/sysadmin/ [R] RewriteCond %{QUERY_STRING} (.+) RewriteRule ^/sysadmin/(.*)$ http://web9.ias.csusb.edu/sysadmin/$1?%1 [P] RewriteRule ^/sysadmin/(.*)$ http://web9.ias.csusb.edu/sysadmin/$1 [P]
On the wiki machine, add the following line to LocalSettings.php.
$wgServer = "http://csci.csusb.edu";
When you make and test these changes, you may need to turn caching off as described in #Control caching. After the system is working, then turn caching back on.
This may be due to SELinux. To check if SELinux is enabled, look inside the following file.
/etc/selinux/config
If SELinux is enabled, then either configure it to allow httpd to connect to port 11211, or disable SELinux altogether. To disable SELinux, simply edit the above file so that the following line appears uncommented.
SELINUX=disabled
After expanding the media wiki tar ball, and then renaming it to sysadmin (or whatever), you need to change the ownership of the directory and the ownership of all its contents to apache user.
chown -R apache:apache sysadmin
Also, check that /etc/selinux/config has SELinux disabled.
If the wiki folder is in your home directory, you need to set the execute bit on your home directory to allow apache user to enter into subdirectories. In this case, do the following. (Replace username with your username.)
chmod +x /home/username
To enable uploading of a a file type, such as ppt, you add the following line to LocalSettings.php.
$wgFileExtensions[] = 'ppt';
However, for ppt, this change is not suffd, or turn off the checking operation by adding the following line to LocalSettings.php.
$wgVerifyMimeType = false;