Setting Up MediaWiki on an Apple Mac
05 Jan 2013 - Nic Ho Chee
After one too many issues with a Hackintosh and a short but painful trip to an Apple store my MediaWiki Windows installation needed moving across into the unknown realms of OSX. After some surprising turns the install worked and the steps have been captured for posterity.
What Do I Need To Try This Out
- MediaWiki. I'm using 1.20.0 which can be picked up here http://www.mediawiki.org/wiki/Download.
- XCode and the Command Line Tools for XCode. DL XCode from the Apple App Store, you'll need to pick up the Command Line Tools for XCode from here; https://developer.apple.com/downloads/index.action#
- Libltdl. You can pick this up from here; http://www.gnu.org/software/libtool/
- Imagemagick. Use 6.7.2, which you can pick up from here; ftp://ftp.imagemagick.org/pub/ImageMagick. I don't want to use MacPorts, so I couldn't use the built version on ImageMagick.org.
- Mamp. The installation works with 2.1.1 which can be picked up from here; http://www.mamp.info/en/index.html
- MediaWiki Math Extension. Download the 1.19 version; http://www.mediawiki.org/wiki/Special:ExtensionDistributor/Math
- Ocaml. Download the 4.01 version; http://caml.inria.fr/ocaml/release.en.html
- LaTex. Download the 2.1G version; http://www.tug.org/mactex
- Ghostscript. Download the 9.06 version; http://www.ghostscript.com/download/gsdnld.html
- Download and install XCode and the Command Line Tools for XCode from the App Store. There should be nothing much to this step…
- Download and install libltdl. Make sure that it isn't the MacPort version. You'll need to carry this out from the command line:
- Download and install the non-MacPort version of ImageMagick. I did this from inside the /tmp area, however you can do this from any temp folder. Run the following from a command line:
- Install MAMP, which has a nice wizard for you to work through. Some things to check:
- There were some oddities with Mamp PRO that I didn't want to take the time to sort out, so only got basic Mamp running.
- Change the installation directory to someplace logical, like Applications > Mamp.
- Create a folder under Users/<username>/Sites and change the Apache directory to point to that.
Installing MediaWiki. There are a few things that will need to be done before you start the MediaWiki installation process:
- Untar the MediaWiki tarball to Users/<username>/Sites and change the foldername to mediawiki.
- Turn off arbitrary scripting in the images upload directory, you'll need to add some code to the httpd.conf file under Applications/MAMP/conf/apache/httpd.conf. Add the following to the script:
- Restart the Apache server.
- Start the MediaWiki installation:
- Change the database password to something useful.
- Create a Wiki user, ZomboidRelic9 for example.
- Create a sensible password for your user.
- Once the process is complete, copy LocalSettings.php from its folder to the MediaWiki root.
This is really handy if you're looking to embed math notation like this... ...into your wiki posts.
- Install Ocaml. This should be relatively straightforward once you DL and run the binary DMG.
- Install LaTex. Again this should be relatively straightforward once you DL the PKG. Make a note where it has been installed to, it should be something like /usr/local/texlive/2012/bin/x86_64-darwin
- Install Ghostscript. This comes down as a tar ball, untar this somewhere helpful and from the command line.
- Installing the Math extension. Unfortunately it looks like there are quite a few things you'll need to do to get this working:
- Download the tarball
- Untar it to your mediawiki extension directory:
- Add the following to your LocalSettings.php file:
- Run the mediawiki update script from a command line.
- Create a socket connection. Again from the command line:
- Build texvc:
- Set the paths for latex/dvips etc… look in Render.ml in the /Users/<username>/Sites/mediawiki/extensions/Math/Math folder. At the top of the file, hardcode the paths to where the applications exist in your system. Then from the command line:
- Add a path to texvc in LocalSettings.php. It should look something like:
- Look in the LocalSettings.php file and uncomment the line "$wgHashedUploadDirectory = false;". You'll need to create the required archive/thumb and temp directories as the attached comment suggests.
- Add some test Math xml to your root wiki page.
- Your wiki will be cached, so to reload your root MediaWiki page, add "?action=purge" to the end of the URL to force it to take account of the changes you've been making.
- Look in the directory /Applications/MAMP/Library/bin/envvars and comment out the lines which repath the dynamic linker!
- The math extension and mediawiki ends up generating the incorrect path for the pngs. It looks like it creates something from the root of the filesystem rather than relative from localhost. For example the following generated URL will not work; http://localhost:8888/Users/<username>/Sites/mediawiki/tmp/0/c/1/XXXX.png.
There is a hacky fix, however. Grep for _linkToMathImage in the MediaWiki source and add the following code to replace the Apache document path:
Purge the wiki cache and you should be able to add Math notation to your hearts content and create pages like this: