WordPress Plugins: Linux Mint Localhost

Featured image of article: WordPress Plugins: Linux Mint Localhost

A local installation of WordPress is a useful way of developing sites – you can muck about on your site without the world seeing the results of your experimentation.

Although you could develop your site on a remotely hosted test server, working on a locally installed version of WordPress is more private. In addition, working locally is usually quicker and more productive – you can clip along at a rapid pace even when your internet connection is patchy.

When I recently set up a localhost WordPress installation on Linux Mint 14, I encountered problems when trying to upload and activate plugins.

When the filesystem can’t be accessed directly, WordPress will ask for permission to access files via FTP. This results in a dialog like this when you try to update a plugin (or carry out similar actions):

WordPress request FTP accessThis problem occurs when Apache is running under a different user to the WordPress filesystem owner. WordPress doesn’t have permission to change your files directly – so it asks for FTP access.

This is problematic in a localhost install – where files are not accessed via FTP. Luckily, there’s a fairly simple solution.

Find Out the Apache User

  1. Create a text file called whoami.php
  2. Paste this into whoami.php:    
    <?php echo(exec("whoami")); ?>
  3. Save whoami.php in your localhost root (typically /var/www/ on Ubuntu or Mint)
  4. Navigate to http://localhost/whoami.php
  5. This will return the user that your instance of Apache is running under

Give the User the Correct Permissions

The easiest fix to this issue is to give file ownership of the directory holding the WordPress files to the user that is running Apache. In my case, the Apache user was www-data, and the WordPress installation in question was located at /var/www/test.

Open a terminal (ctrl+alt+t) and enter:

sudo chown -R www-data /var/www/test

Where “www-data” is the user returned by whoami.php and “/var/www/test” is the path to the folder that contains your WP installation.