How do I get the right permissions for WordPress running Apache on Debian

I’m trying to set up a WordPress site on a LAMP stack on Debian 6.0. From the WordPress documentation (and my experience on shared hosts) the correct permissions should be as follows

All files should be owned by your user account, and should be writable by you. Any file that needs write access from WordPress should be group-owned by the user account used by the webserver.

I’ve managed to setup my server to have 755 permissions on all directories and 644 on all files. However, WordPress is still not able to create folders for uploads and upgrades. I’m guessing that this is because WordPress is not running as my user account, but as www-data and therefore it needs group write permissions.

How do I make WordPress run as my account? Or am I on the wrong track?

I’m new to this, having outgrown shared hosting and setting up my first VPS. I would really appreciate it if you could answer in as much detail as possible.

1
1

Many of the examples assume you’re not the only person running stuff on the server, or that suPHP or some other utility is running to make PHP run as a user other than the web server.

With a basic Debian LAMP install, where PHP runs as the www-data user, it’s safe and normal to set ownership of everything under the web server document root directory as owned by www-data:www-data with permissions 700/600 or 770/660.

The only issue then is when you (as a user) want to put files into those directories, in which case you either need to add yourself to the www-data group (and use the second set of permissions above) or do it via sudo or as root, and remember to set the permissions later.

Personally, now that WordPress can auto-update and auto-install plugins and themes, I just set everything to www-data:www-data and let WordPress handle it, works fine.

The walkthroughs that talk about setting permissions to your username assume PHP is running as you, through as I say, some other extension or Apache mod.

Leave a Comment