almosteffortless.com | djangoproject.com | python.org | linux.com
demongin.org - Wordpress Upgrade Error on Debian/Ubuntu

Wordpress Upgrade Error on Debian/Ubuntu

A quick guide to responding to a fairly obscure WP error encountered during an upgrade/migration.


Saturday, 2010-02-06 | On the Internet, Programming

"Actually, he's usually just in there with some Bibb lettuce and a handful of Rubino beets."

Chris Onstad

While migrating some WordPress blogs from a Debian to a Ubuntu server, I hit a tiny snag that cost me 15 minutes or so.

After I copied all the files to /usr/share/wordpress/wp-content, I created symlinks in /etc/wordpress to the config-* files in the /usr/share/wordpress doc root, restored the databases, replaced the Apache config files and tried to fire up the sites, I got this error:

The config file for the specified host is not under an allowed path
A quick grep of the files in /usr/share/wordpress revealed the source of the error. It turns out that there's a key difference between the Ubuntu and Debian packages for Wordpress in the /etc/wordpress/wp-config and it is the following lines:
    $allowed_paths = array('/etc/wordpress');
    if (!in_array(dirname(realpath($debian_file)), $allowed_paths))
        die("The config file for the specified host is not under an allowed path");
Basically, this checks all config-* files that are supposed to be used and makes sure that they live in /etc/wordpress. This is probably a security thing: in the Debian package, they can live almost anywhere on the file system (e.g. in a user's home dir) and thus could become subject to tampering.

As you'll recall, I mentioned at the start of the article that I created symlinks in /etc/wordpress to the config-* files that I had been maintaining in /usr/share/wordpress. So, in order to get things working again, I had to dump the symlinks:
root@lana:/etc/wordpress# ls -la
total 16
drwxr-xr-x  2 root root     4096 2010-02-06 15:43 .
drwxr-xr-x 99 root root     4096 2010-02-06 14:06 ..
lrwxrwxrwx  1 root root       46 2010-02-06 15:40 config-rustypipes.org.php -> /usr/share/wordpress/config-rustypipes.org.php
lrwxrwxrwx  1 root root       53 2010-02-06 15:40 config-sweetheartbrigade.com.php -> /usr/share/wordpress/config-sweetheartbrigade.com.php
lrwxrwxrwx  1 root root       54 2010-02-06 15:40 config-zombiesatemyashley.com.php -> /usr/share/wordpress/config-zombiesatemyashley.com.php
-rw-r--r--  1 root www-data  194 2009-08-24 11:23 htaccess
-rw-r--r--  1 root www-data  932 2009-08-24 11:23 wp-config.php
root@lana:/etc/wordpress# rm config-*
...and move those config-* files into /etc/wordpress:
root@lana:/usr/share/wordpress# mv /usr/share/wordpress/config-* /etc/wordpress/.
Once I did that, the blogs started right up, no complaints.