Solving the FTP credentials WordPress request in Vagrant

For my latest client work I’ve jumped on the Vagrant wagon and decided to give it a go.
I’ve also taken the shortcut provided by PuPHPet to have a Vagrant machine up and running in minutes.

And then WordPress

After enjoying the easy WordPress installation and usual clean-up I’ve tried to install the WordPress Importer plugin to import theme unit test content into my local version. The rolling sequence of rainbows and unicorn my Vagrant experience had been so far stopped on its tracks to this screen

FTP what?
FTP what?

where WordPress (it’s italian) is asking me the FTP credentials. I have no idea what those might be.

The web to the rescue… maybe not

A quick search via Google did not yield any constructive answer but “you can reach the files and folders via the shared folders: why bother setting up FTP?”.

I’m dealing with a non average problem here

Since the solution to my current problem is not on the first page of Google results I must be dealing with a non-average problem and hence some reasoning is in order.
My first attempt at using the chmod and chown commands was not successful and the solution came from this thread on Stackoverflow (always praise Stackoverflow): after downloading the package from PuPHPet I’ve modified the lines about synced folders in Vagrantfile

 data['vm']['synced_folder'].each do |i, folder|
    if folder['source'] != '' && folder['target'] != '' && folder['id'] != ''
      nfs = (folder['nfs'] == "true") ? "nfs" : nil
      config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{folder['id']}", type: nfs, owner: "www-data", group: "www-data"

What I’ve done is modifying the instruction that’s setting up the synced folders to change their ownership from the vagrant user to the wwww-data user, the one Apache server will use to read and write in the www folder.
While the above solution is probably not the best one it is safe to use during local development.

5 thoughts on “Solving the FTP credentials WordPress request in Vagrant

I appreciate your input