Automatically Set FTP Credentials for WordPress in a Development Environment

Web Design & Development
This entry is part 2 of 4 in the series WordPress Development Environment.

One of the first things I noticed in the WordPress development environment I set up using VirtualBox and Ubuntu (see my previous post) was that whenever I wanted to install or upgrade a theme, plugin, etc. I had to enter my credentials in order to allow the Apache server to upload files to my wordpress folder in Ubuntu. It worked just fine once I entered “localhost” for the Hostname, “josh” (my Ubuntu username) for the FTP Username, and “password” (my Ubuntu password) for the FTP Password.

This was going to get fairly annoying as I tried out various plugins and themes, and I knew there had to be a better way. I quickly found this article that listed the necessary code to add to wp-config.php. I simply added the following code and now I don’t have to enter credentials every time I want to update something in my development environment:

define('FS_METHOD', 'ftpext');
define('FTP_USER', 'josh');
define('FTP_PASS', 'password');
define('FTP_HOST', 'localhost');
define('FTP_SSL', false);

Remember, this method should only be used in a development environment, not for a site accessible to the internet!