Special Characters and MediaWikis Do Not Mix

I have run a MediaWiki wiki for my house on campus for close to two years. When I set it up, I gave it the name “Saint Claude de La Colombière Men’s Catholic House,” and since MediaWiki accepted this name complete with two accented characters, I assumed it wasn’t a problem. For an unknown reason, it became a problem today. It started throwing the annoying “Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 122880 bytes) in /home/www/claude/w/includes/Revision.php on line 361” errors. I tried increasing the memory allocated to PHP, looking through Apache log files, and upgrading the version of the MediaWiki software.

After at least an hour of frustration accumulated throughout the day, it occurred to me that this only happens on one page: the “About” page. This page, in standard MediaWiki fashion, is actually called: “Saint Claude de La Colombière Men’s Catholic House: About.” Then it hit me that perhaps those accented characters weren’t such a good idea after all. As soon as I changed the value in the LocalSettings.php to something more reasonable and accent free:

$wgSitename = "Saint Claude de La Colombiere Men's Catholic House";

everything started working again as normal.

I would be very curious to know why this worked in the past. I suppose it could have to do with my versions of Ubuntu Server, Apache, PHP, MediaWiki, etc. However, it’s one more thing to check when PHP starts throwing out of memory exceptions.

Edit: It turns out that increasing the memory to PHP was the solution as today I started experiencing the same error on other pages. I increased the LocalSettings.php memory limit from 20 MB to 32 MB.

ini_set( 'memory_limit', '32M' );

and this (actually) solved the problem. Before, I was editing the php.ini file, and it would appear that the LocalSettings.php was overriding the global value even though it was higher. Special characters may still be a bad idea.

Configure a Reverse Proxy with Apache

In a previous post, I discussed the details required to set up Subsonic on Ubuntu Server. The problem with Subsonic is that it runs on Tomcat on a non-standard port. The rest of my web applications run in Apache on port 80. Therefore, it would be nice if instead of having to go to http://athos.zacintosh.com:8180/subsonic/, I could simply go to http://athos.zacintosh.com/subsonic/. The solution is called a reverse proxy. Reverse proxies can do things like load balance between multiple web servers or simply make resources on an internal web server available externally. In this case, I am using a reverse proxy to make a web application available on a different port available on the standard port 80.

The set up is fairly simple. On Ubuntu, it should be as simple as issuing this command (as root) to enable the proxy modules:

a2enmod proxy_http

Next I inserted the following into /etc/apache2/conf.d/subsonic.conf to make it available on all websites running on my server. If you only wanted it to be available for a single website, you could insert this into a site inside of /etc/apache2/sites-available/.

ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
ProxyPass /subsonic/ http://localhost:8180/subsonic/
ProxyPassReverse /subsonic/ http://localhost:8180/subsonic/

The configuration above says to not proxy all requests (not act as a forward proxy server). The ProxyPass and ProxyPassReverse set up the actual retrieval of data from Subsonic running on Tomcat. You need to replace the localhost and the port number with the specific items for your configuration. Finally, you need to reload the Apache configuration:

/etc/init.d/apache2 force-reload

Now Subsonic should be available on port 80 just like everything else running on your web server with Apache.

AWStats on Ubuntu Server

Since I am running this blog on my own server, I decided I should probably set up some log parsing. My personal website is hosted by Nearly Free Speech, and they provide AWStats for statistics. Another site I administer is hosted by DreamHost. DreamHost provides Analog web statistics. After playing with both, I decided to use AWStats.

Ubuntu Tutorials has provided a nice tutorial about setting up AWStats on Ubuntu. I configured my sites individually with no default site in the following files:

/etc/awstats/awstats.blog.lundscape.com.conf
/etc/awstats/awstats.claude.zacintosh.com.conf
/etc/awstats/awstats.wiki.lundscape.com.conf

This means that browsing to “http://domain.tld/awstats/awstats.pl” as they suggest won’t work. Instead, I append the site to the end of the string like this: “http://domain.tld/awstats/awstats.pl?config=blog.lundscape.com”.

Also, rather than adding entries to my crontab, I simply added a script to my “/etc/cron.hourly”:

#! /bin/bash

/usr/lib/cgi-bin/awstats.pl -config=blog.lundscape.com \
	-update > /dev/null 2>&1
/usr/lib/cgi-bin/awstats.pl -config=claude.zacintosh.com \
	-update > /dev/null 2>&1
/usr/lib/cgi-bin/awstats.pl -config=wiki.lundscape.com \
	-update > /dev/null 2>&1

This automatically updates my AWStats every hour whether I view my statistics in a web browser or not.