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. Open ports 80 and 443.
The following command installs mysql server, apache web server and php.
yum 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 make
The wget command in the following step may not be installed on your system. If it isn't, then install it as follows.
yum install wget
Install Objective Caml. As a non-root user, do the following.
wget http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-3.11.2.tar.gz tar -zxvf ocaml-3.11.2.tar.gz cd ocaml-3.11.2/ ./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.4.13-stable.tar.gz tar -zxvf libevent-1.4.13-stable.tar.gz cd libevent-1.4.13-stable ./configure --prefix=/usr make sudo make install
Install memcached, because we will configure mediawiki to use this for caching.
wget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz tar -zxvf memcached-1.4.4.tar.gz cd memcached-1.4.4 ./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.
Get the most recent stable release of mediawiki.
Extract and move to a folder under /var/www/html.
Rename the mediawiki folder to some related to what you want to
appear in the url, but keep it different.
For example, if you want the wiki to be accessed through ''gp,''
then name the folder gp_wiki.
Set the owner of the media wiki files to apache.
chown -R apache:apache turner_wiki
Start (or resart) web server.
service httpd start
Start web-based configuration by going to http://localhost/[your-folder-name] 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.
mv config/LocalSettings.php . rm -rf config
Suppose you installed mediawiki to /var/www/html/gp_wiki.
Create file /etc/httpd/conf.d/wiki.conf and add the following line
to it.
(Remember to replce ''gp'' in all these commands with the name of your wiki.)
Alias /gp /var/www/html/gp_wiki/index.php
(Remember to restart httpd after making the above change to its configuration file.)
Add the following lines to the bottom of LocalSettings.php.
Make sure you change the line that sets $wgScriptPath
to point to your folder.
And make sure to change $wgArticlePath to match the name of your wiki.
# Configuration by David Turner from this point on. # To clear the server-side cache, simply edit (or touch) this file. $wgLogo = "../logo_135_135.png"; $wgEnableUploads = true; $wgAllowExternalImages = true; #$wgFileExtensions[] = 'pdf'; $wgFileExtensions[] = 'ppt'; # Disable new registrations from anonymous users. $wgGroupPermissions['*']['createaccount'] = false; # Disable anonymous edits. $wgGroupPermissions['*']['edit'] = false; # Don't display edit links to non-logged in users. #$wgDefaultUserOptions['editsection'] = 0; $wgScriptPath = "/gp_wiki"; # Path to the actual files. $wgArticlePath = "/gp/$1"; # Virtual path. This directory MUST be different from the one used in $wgScriptPath $wgUsePathInfo = true; # Enable use of pretty URLs $wgUseTeX = true;
Run the mediawiki build script for math support.
cd /var/www/html/[your folder name]/math make chown apache:apache *
I got Latex support to finally work with the following procedure performed as root.
mkdir /var/www/html/[your-folder-name]/images/tmp cd /var/www/html/[your-folder-name]/images/tmp ../../math/texvc . ../../math "0" cp /root/.texmf-var/web2c/latex.fmt . chown apache:apache latex.fmt cd .. chown -R apache:apache tmp
The remainder of this page describes what I did to set up a proxy in front of mediawiki.
Add the following lines to wiki.conf in order to redirect login page requests to the server's secure port. (Replace 139.182.139.99 with the hostname for your server.)
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{QUERY_STRING} Special:UserLogin
RewriteRule .* https://139.182.139.99%{REQUEST_URI} [R]
Use the following to turn off mediawiki caching.
# Temporarily disable all forms of MediaWiki caching # (for changing and testing configuration). $wgMainCacheType = CACHE_NONE; $wgMessageCacheType = CACHE_NONE; $wgParserCacheType = CACHE_NONE; $wgCachePages = false;
If you want to setup a wiki behind a proxy, then you can try the notes in this section.
This section assumes that the public-facing proxy server is cse.csusb.edu, and the wiki server is listening to port 8080 on 139.182.139.99.
On the public-facing proxy machine, create /etc/httpd/conf.d/turner.conf with the following contents.
RewriteRule ^/turner/wiki$ http://cse.csusb.edu/turner/wiki/ [R]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^/turner/wiki/(.*)$ http://139.182.139.99:8080/turner/$1?%1 [P]
RewriteRule ^/turner/wiki/(.*)$ http://139.182.139.99:8080/turner/$1 [P]
RewriteRule ^/turner/wiki$ http://cse.csusb.edu/turner/w/ [R]
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^/turner/wiki/(.*)$ http://139.182.139.99:8080/turner/$1?%1 [P]
RewriteRule ^/turner/wiki/(.*)$ http://139.182.139.99:8080/turner/$1 [P]
On the wiki machine, add the following line to LocalSettings.php.
$wgServer = "http://cse.csusb.edu";
When you make and test these changes, you may need to turn caching off as described in the previous section. After the system is working, then turn caching back on.
Modify the ''includes/mime.types'' file by adding ''xls'' to the following line:
application/msword
In LocalSettings.php, add the following.
$wgFileExtensions[] = 'xls';
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;