Here is the EC2 setup:

  • Amazon Linux AMI
  • LAMP
  • SFTP (e.g., users jdoe, jsmith, etc)
  • Virtual Hosts (e.g., /mnt/www/site1.com, /mnt/www/site2.com, etc)

I've been able to get Wordpress installed and running. However, the problem is that the auto-updating doesn't work. Setting up FTP is out of the question since it defeats the purpose of setting up SFTP in the first place. Also, the solutions that I came across all seem to require insecure settings. The primary Google hit is at the following link: http://www.chrisabernethy.com/why-wordpress-asks-connection-info/ As far as I can gather, the two primary suggestions are to either chown the WP directory or chmod 777 the WP install. Neither seem very secure after much reading so I'm at a loss at what is the best practice to get around the auto-updating problem.

Suggestion 1 (apache runs as httpd or apache):

# chown -R httpd: /mnt/www/site1.com

Suggestion 2

# chmod 777 /mnt/www/site1.com

Both of the above suggestions work but, as mentioned earlier, neither seem secure. I also tried the suggestions per WP docs to set directories to 755 and files to 644 but that didn't help to make auto-updating work. My best guess is that it's a permissions issue but am not sure where I'm getting things confused.

What is the best practice to get WP auto-updating to work?

Any advice will be much appreciated. Thanks in advance!


1 Answer 1


Best Practice #1

One of the best practices is to let the PHP process to run under a different user (in your case: jdoe, jsmith, etc) than the web server user (in your case: httpd) and let only these users have the write permission. Of course, your web server may still need read permission for all these files.

For this solution to work, you may need to go with PHP-FPM that is available with Amazon Linux AMI. Please note that it's tricky to make Apache 2.2.x to work with PHP-FPM. However, Apache 2.4.x integrates well with PHP-FPM (that works as a proxy). Alternatively, you may choose Nginx as the web server that has an additional option (via unix sockets) to integrate with PHP-FPM.

Best Practice #2

Make no changes in your current server. Let WordPress handle SFTP connections. For this to work, there may be several methods. However, I use the following...

  1. Install SSH SFTP Updater Support plugin
  2. Enter the following credentials in wp-config.php or just keep them ready to be entered on step #4. :)

    • define('FTP_USER', 'username');
    • define('FTP_PASS', 'password');
    • define('FTP_HOST', 'localhost:22'); // You don't probably have to change this.
  3. Go and install a plugin / theme. You'd be presented with an error message, like... Error: There was an error connecting to the server, Please verify the settings are correct.

  4. Choose "SSH2" as the connection type (and enter the credentials, if you haven't already, in step #2) and then click "Proceed" button.

  5. Be Happy!

  • Best practice #1 sounds like a good idea but am not sure how to get it to work. Is PHP-FPM the same as using suexec? I tried out the SSH SFTP Updater Support plugin and instead of an error, it says that "All updates have been completed." but when the plugins page is reloaded, the plugin that should have been updated remains un-updated. Also, just to test it out but when trying to do a re-install of WP, it returns the error "Unable to locate WordPress Root Directory. Installation Failed."
    – jiminy
    Sep 10, 2013 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.