How to allow WordPress updates, plugin and theme installs in Amazon EC2

Hello, so I just had a bit of a fight with WordPress trying to get it to install updates automatically for itself and my plugins. I have manually been installing updates by connecting through ssh to my Amazon EC2 server which is little too complicated to do often. So this guide presumes you have installed WordPress in Amazon EC2 server.

Don’t do: I installed vsftpd and configured vsftpd.conf properly. I also opened up couple of ports in my Amazon EC2 Ubuntu instance. After half an hour later I was still trying to get WordPress to connect to my FTP server in order to get updated. Then I kind of realised that it probably isn’t necessary to setup FTP server in the same server that holds all my WordPress data.

Do: I opened up wp-config.php and added a line:define(‘FS_METHOD’, ‘direct’);
which completely seems to override the FTP credential page and straightforwardly starts updating. Still one more problem occurred in unpacking the updates: Could not create directory
This error was resolved by changing the ownership of the directory where WordPress is installed. Before changing ownership make sure your username belongs to www-data usergroup. Then run:sudo chown www-data:www-data /var/www/wordpress/ -R