EC2 WordPress install asks for connection info when auto-updating

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!