Saturday, April 09, 2016

Installing and Configuring a Mediawiki wiki on Mageia5

I started a MediaWiki wiki for my hobby, to serve as a convenient place to collect and centralize all the bits of information that I find scattered about the internet.

Creating such a wiki can be a daunting task, but if broken down into small tasks, it can be done. The most difficulty I had was that there were no specific instructions for Mageia. The best general instructions I could find were from the Mediawiki site, but were  for Ubuntu. Mageia configures its default configurations slightly different.

I chose to tun the wiki and its associated webserver and database in a virtual machinate using VirtualBox, so we can tackle that first assuming that you already know how install and configure VirtualBox.

Installing A Minimal Mageia Base
During the installation, deselect all the pre-configured options, but do select the option to select individual packages. You will select a minimal install with no X11 or documentation, but with urpmi.

The remaining installation is pretty straightforward and quick. On re-booting, you will see a prompt; you can log in as root. At this point, you'll need to use vi to edit files, so brush up if your vi-fu is rusty.

Modify /etc/group to add your personal account as a member of the wheel group and modify /etc/sudoers to you liking as to whether or not a password will be required.

Then we will remove the DVD-based repositories, add some web-based ones, perform and update of our base system, and then install the additional applications we need.

# urpmi.removemedia -av

# urpmi.addmedia --distribute --moralist 'http://mirrors.mageia.org/api/mageia.5.x86_84.list'

# urpmi --replacefiles --auto-update --auto -v && urpmi --replacefiles --auto-update --auto -v && shutdown -r now

The last instruction to run the command twice is at the suggestion of Mageia when doing a distro upgrade. here, it's just added insurance that all the files will be updated before you reboot.

Install Something to Send Mail From Your Wiki
We will need an application to send mail from our wiki. Rather than use a heavyweight like sendmail, I prefer the very lightweight /bin/mail, and that requires some additional configuration.

# urpmi mailx

Make the system's /etc/alternatives aware of /bin/mail and make it the default selection.

# update-alternatives --install /etc/alternatives/sendmail-command sendmail-command /bin/mail 1 

I needed to configure /etc/nail.rc to accommodate  my Gmail account.

Install Needed and Useful Applications
Let's add a few things to make it easier on ourselves. We need an ssh sever so we can log in remotely (actually while we log in from the host while the server runs in headless mode) and my favorite file manager, the Midnight Commander.

# urpmi openssh-server mc

Now it's time to not only install MediaWiki, but all the things that will be needed. In the Ubuntu tutorial and in the web-based MediaWiki setup procedure you will follow later, you will learn what you need, but here it is all laid out beforehand to make our job easier.

# urpmi task-lamp php-apc mediawiki-mysql git imagemagick 

Configure PHP
The /etc/php.ini file needs to be modified to reflect your timezone and allow large files to be uploaded. Here's the examples:

Date]              
; Defines the default timezone used by the date functions  
; http://php.net/date.timezone  
;date.timezone = "US/Eastern"

That web address will help you locate the appropriate value for the timezone.

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize 
upload_max_filesize = 20M

Configure Apache
Apache is installed with some good and useful pre-made configurations, but at the advice of MediaWiki, we should make the image upload directory more secure so bad actors can't do bad things.  

Edit /etc/httpd/conf/sites.d/mediawiki.conf to add:  
         
    # Ignore .htaccess files 
    AllowOverride None      
    # Serve HTML as plaintext, don't execute SHTML 
    AddType text/plain .html .htm .shtml .php .phtml .php5 
    # Don't run arbitrary PHP code.    
    php_admin_flag engine off      
    # If you've other scripting languages, disable them too.    

Start Apache : # systemctl start httpd.service

Start MySQL: # systemctl start mysqld.service

Make MySQL Safer
You should launch a special configuration application to make the MySQL server more secure and establish a root password.

# mysql_secure_installation

Configure MediaWiki
The initial configuration of our MediaWiki is done through a  web-based interface. This is fine if you're installing it on real hardware, but we're doing it on a headless virtual server with no X server. Theoretically, it should be possible to install a modern web browser like Firefox on our headless, X-less sever (it's only an X client after all) and run it over ssh on our local X-server.

Use ssh to access the server, install and launch Firefox to start the MediaWiki configuration.

During the web-based configuration, take the time to read everything it says and understand everything it says and make a note of every entry you make.

By the way, if you futz up at this point, just delete that one file and begin the web-based configuration again. It can be found at /etc/mediawiki/.

One Last Thing
We need to have good security for our server since it will face the Internet. To do this, we'll use Mageia's msec tool and we'll uninstall all applications we will no longer be using.

# urpmi msec && msec -l server
# urpme firefox && urpme --auto-orphans

Access Your New Wiki
Now here's the thing, the URL to access you new wiki is http://yourdomain/mediawiki. There are some valid reasons for making it so, but it's awkward. My workaround is to edit the default Apache file index.html to become a "welcome page" with a link to the funky address of the wiki.

Make Your URLs Pretty
If you don't like the ugly PHP URLs, you can find instructions on how to modify Apache to show prettier URLs. I didn't feel the need to do that.

Make a Custom Logo
The default logo for your site is located at /usr/share/mediawiki/skins/common/images/wiki.png. 
Make you own logo, name it wiki.png and replace the default logo.

REFERENCES

Installation Requirements

Installation Guide

System Administration

Running MediaWiki on Ubuntu  <-- followedl="" good.="" i="" it="" p="" pretty="" s="" what="">

No comments: