Like what you're reading? Want to get rid of ads? Donate some BTC and help me stop relying on AdSense. BTC Address: 1E4TGB9e4mwfUusg4XHnte1Szi1gDFWDd9

Wordpress Settings Page Segfaults Apache

I’ve been struggling for over a month with Wordpress Multisite (aka Network) crashing Apache every time I go to the Network Settings or General settings pages. At first I was convinced that it was a plugin issue but after much research and testing it turns out that you need to be very careful if you configure an FTP user for plugin and theme installation in your wp-config.php file. Here’s how to fix the issue:

What the issue is

Like I mentioned, each time I went to the Network Settings page of my Wordpress Network or any General settings page of an individual site on that network, I would get a blank error page. When I inspected the logs I found that PHP said nothing about this and there wasn’t even an entry in the site’s error log. What I did find were entries in Apache’s system error log in /var/log/apache2/error.log which noted that Apache was segfaulting whenever I went to the settings page. The cause of the issue was unclear and when I inspected the core dump file using gdb I still found nothing. For reference, the issue happened on a Linode 2G VPS running Apache 2.4 and PHP 5.5.9 on Ubuntu 14.04 as well as a fresh new DigitalOcean droplet running the same stack.

Reproducing the issue

At first I believed the issue was due to WPMU Dev’s Domain Mapping plugin which I had just installed and activated on the site. As soon as I installed and activated it I could no longer access my Wordpress settings page.

So I threw away Wordpress and set up the network again from scratch. This time I used a different domain mapping plugin which I installed manually and all was well. I figured that it was that plugin causing the issue and continued on installing WPMU Dev’s Dashboard plugin. Then, everything broke again. This time I was convinced it was the dashboard plugin after all. Turns out I was wrong.

I went back a third time, deleted the database, deleted the Wordpress files, and installed Wordpress anew for a third time. This time I avoided any and all WPMU plugins. I installed domain mapping and Akismet and everything was fine. Then I decided I could use the Wordpress importer tool. Having configured Wordpress to use a special username and key files over SSH in my wp-config.php I went ahead and installed the importer through the Wordpress dashboard instead of manually. Installation went fine and then, suddenly, I could no longer access the settings pages anymore.

At this point I knew that the issue was not plugin related. What we had here was a case of Wordpress FTP user definitions somehow causing Apache to crash. I still don’t know how it happened or why, but I know how to fix it now.

The fix

If you have configured FTP updates for Wordpress then your wp-config.php file may have entries that look like this:

/* Wordpress FTP credentials */
define('FTP_PUBKEY', '/path/to/');
define('FTP_PRIKEY', '/path/to/private_key');
define('FTP_USER', 'wordpress-user');
define('FTP_PASS', 'your-password');
define('FTP_HOST', '');

After you set this up everything will still work just fine in most cases. It isn’t until you try to install a theme or plugin through the dashboard that suddenly everything breaks. To prevent this from happening, fix the issue, and restore access to your Network settings page and General options pages, you’ll need to add the following line above your other FTP constant definitions:

define('FS_METHOD', 'direct');
// Other options include: ssh2, ftpext, ftpsockets

Before you enable this and go on your merry way, be aware that if you haven’t set permissions properly or haven’t optimized your server configuration for security, using the ‘direct’ method can open you up to some serious security holes. I would recommend you use ssh2 to start and only use the other methods as a last resort. In my case, direct worked and is secure because of some other settings I have in place as well as the way my permissions are set up.

It took me over a month to figure this out and I have to say that WPMU Dev support was very disappointing. They were talking to me like I was someone who didn’t know what HTML was when it should have been clear from my request that I am an experienced developer and don’t need instructions on how to find my PHP version or update Apache. That’s with their platinum package or whatever they call their highest tier plan as well. Oh well… it’s fixed now. I hope this helps someone else in the future.

Web development

« The Three Virtues of a Great Programmer Ghost: The Overrated Blogging Platform »