Skip to content

MediaWiki: fixing “wfMkdirParents: failed to mkdir”

The server crashed again last night (yeah, when it crashes, it seems to always happen when I’m not immediately available). Weirdly, the 1and1 monitoring tool only detected 20 minutes of HTTP downtime: it thought it was back online, while in fact we had an ongoing global downtime of over 4 hours. Anyway, as usual after a hard reboot, I then browsed through the Apache logs (in /var/log/apache2) to see what the heck happened. Some insufficient memory, like last time. But I also found tons of lines looking like:

[Mon Mar 12 19:16:43 2012] [error] [client] PHP Warning:  wfMkdirParents: failed to mkdir "/xxx/images/thumb/7/7a/Hospital_Tycoon_-_bonus_code_page.jpg" mode 511 in /xxxx/includes/GlobalFunctions.php on line 2324, referer:

Which means that MediaWiki was failing to write to the thumb folder (the folder where the scaled down pictures are cached). Searching a bit around, I found (source 1, source 2) 2 first-line possibilities: non more space and incorrect permissions.
To check for space, use df-h. That wasn’t it, I had space remaining, even though not plenty.
We already had permissions issues a while back, because of a faulty MediaWiki upgrade script, and indeed that seemed to be the problem: although the images folder was fine, the thumb subfolder didn’t belong to the httpd user nor had 777 permissions. So I chowned it to the httpd user (syntax: chown user:group thumb -r), but another option would have been to chmod it 777 (syntax: chmod 777 thumb -r).

Posted in MediaWiki, servers.

5 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Gabriel says

    Thanks for your article.

    It could be a solution, but I am a bit concerned about security and I will never give 777 permissions to folder in wich anyone can upload code and execute it.

  2. patheticcockroach says


    Modifying permissions to 777 is the quick’n dirty way indeed, that’s why I also proposed as a first option to give proper ownership ๐Ÿ˜‰

  3. Gabriel says

    The solution is to chown -R the directory images with wathever user is run by the apache server.

    chown -R www-data:www-data /wiki/images

    permissions for that folder could be 755 but never ever 777

  4. Gabriel says

    Wowww youยดre fast.
    Congratulations ๐Ÿ˜€

  5. patheticcockroach says

    Yeah due to connection issues I put all comments to premoderation, so I try to be responsive when I happen to be online ๐Ÿ™‚

Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA