GUIDE: Develop for WordPress locally, using Vagrant and VVV (2019 edition)


There are many reasons why you may want to develop locally, rather than on a live server, but tools like MAMP or XAMPP may have run their course (and may also prove difficult to work properly on certain setups, both on Windows and Mac).

You may also need a local environment to teach coding, for example, where buying a hosting for each individual student isn’t an option.

The solution is virtual environments, that perfectly replicate a whole live server and give you all the tools (and more!) you may find on any regular hosting.

This guide will show you how to create a virtual server, using Windows 10 (even though the process is almost identical on Mac), and start developing a new theme or plugin for WordPress, in minutes.

STEP 1

We need to download/install all necessary tools.
I will use the latest PowerShell v.7 (available for Win, Mac and Linux), however, Git Bash and the built-in PowerShell v.6 are also fine).

We will also need the latest VirtualBox and Vagrant.

Once installed both, reboot your machine (you may need to reboot more than once to complete both installations).

STEP 2

Now create a new folder on your Drive, where all our WP development will take place, you can call it vagrant-local, or something else. Let’s keep it open in Explorer.

If you installed the PowerShell v.7 you should see a new menu item when right-clicking inside the new folder, so go ahead:

If you are using Git Bash, you might also use Git Bash Here, while if you are on the default Windows PowerShell:

Once the command-line shell of your choice is up, run this command:

vagrant plugin install vagrant-hostsupdater

This will install a plugin for Vagrant that will automate domain mapping, when creating your local WordPress site(s).
If the command succeeds (you don’t see any errors), then both Vagrant and the plugin, installed successfully.

STEP 3

The beauty of Vagrant is that, through a single config file called VagrantFile, you can setup a whole server and install WordPress sites, using a single command.
It happens that 4 amazing humans have already compiled the best possible config file for Vagrant & WordPress, known as the “Varying Vagrant Vagrants”.

With the VVV config file, we won’t even need to worry about setting up Vagrant, nor installing WordPress manually.

So let’s download the VVV files into our newly created folder, by running this command in our shell (DON’T forget the final dot!):

git clone -b master git://github.com/Varying-Vagrant-Vagrants/VVV.git .

You will then see all the contents of the git repository, inside your folder.

Now download this custom VVV config file and copy it into the folder, it will provide a custom for VVV that will install 1 WordPress site (you can add more later), as well as PHP 7.3 (the best version yet) and a couple other tools (PHPMyAdmin and a PHP debugging tool) .

Now, all we have to do is run the last command, and Vagrant will setup a full virtual server, all the necessary libraries, WordPress and map the new site to a real-looking urlthat we can use in our browser.

Run in the shell (from the same folder):

vagrant up

Enjoy the console log :)

For the full VVV documentation, or in case of errors, head over to the VVV site.

STEP 4

Once the process has completed and there are NO errors, the VVV dashboard will display nicely on your browser, simply by going to http://vvv.test/ or http://one.wordpress.test (your new local WP site!).

If you don’t see this screen, then something didn’t work out in the provisioning part of Vagrant.
I suggest you delete the VM image it created (you will find it inside a folder called VirtualBox VMs on your drive) , as well as everything inside the vagrant-local folder, EXCEPT the vvv-custom.yml file, and you start over from STEP 2.

You will find all the WP files, where your work will be done, inside www\wordpress-one\public_html (inside the folder we created earlier).
You can then access the WP backend by going to http://one.wordpress.test/wp-admin and using admin / password as your login.

Have fun & Happy Coding! :)

Jany Martelli

I’m a Digital Consultant, Front-End Developer, specialized in WordPress.
I help companies, professionals and startups grow with technology and a winning digital strategy, I hand-pick and coordinate the perfect team for them, plan projects from the ground-up, develop & deploy websites, online stores and apps.

Privacy Preference Center

Session

Also called a transient cookie, a cookie that is erased when the user closes the Web browser. The session cookie is stored in temporary memory and is not retained after the browser is closed. Session cookies do not collect information from the user s computer.

They are usually used to temporarily keep track of users' preferences (eg. currency, language, items you place in the cart - in case of an e-commerce website, which this website is not) throughout the website. Other times they are used to make sure the user is not a malicious bot trying to take down a website, hence the cookie cannot be disabled for security reasons.

They are usually harmless (or they should be!) and will go away when you leave the website or close the browser.

PHPSESSID,gdpr[allowed_cookies],gdpr[consent_types],uvc,__cfduid,_gh_sess,PREF
uvc,__cfduid
_gh_sess
use_hitbox,YSC

Analytics

Persistent Cookies.

Also called a permanent cookie, or a stored cookie, a cookie that is stored on a user's hard drive, until it expires (persistent cookies are set with expiration dates) or until the user deletes the cookie.

These cookies are meant to profile the website's visitors and let the admins know who visits their website. Your name is NOT tracked, but your IP, country, browser and device specs, research terms and more, usually is. It helps admins understand what contents their users like best and who is their audience, in order to provide better and more targeted content.

Other cookies have the same functions as session ones: for example, they simply help the browser remember if your Internet connection is fast enough to play high-quality videos next time, or what language you chose for your subtitles.

Some of these might be relatively harmelss, since they were meant to first and foremost help admins to manage their site's audience and content, however they might also be used, to be collected and sold to third parties.

You can check a full explanation of a few of the most common ones here

_ga,_gat,_gid,PREF,VISITOR_INFO1_LIVE,GPS
PREF,VISITOR_INFO1_LIVE,GPS

Advertising

Persistent Cookies.

Also called a permanent cookie, or a stored cookie, a cookie that is stored on a user's hard drive, until it expires (persistent cookies are set with expiration dates) or until the user deletes the cookie.

These cookies are meant to collect your browsing preferences (your searches, the websites you visit, things you like or don't like, personal conditions and things you might not want a third party to know about nor to be sold to someone else).

A vast majority of websites, search engines, apps and social networks, will place these cookies in your browsers because they are showing you ads and making money off them. This is not inherently bad, however the ad you see, comes also with these cookies, to help Advertising Networks to show you even more relevant ads, as well as collect a vast amount of data about Internet users, to then be sold or mishandled in ways that could harm society.

This website shows Ads from Google, therefore it places their cookies in your browser (sorry!).
If you don't wish to be tracked, please adjust your privacy settings here.
We also show Facebook Ads, therefore if you don't wish to be tracked by them, please head over here to change your settings.

Also turn these cookies' consent toggle OFF.

Please understand that not allowing Advertising cookies to be placed in your browser, does NOT mean you will not see ads, you STILL will, but they simply will not be relevant to your own interests anymore.

On Chrome, click here, to block all third party cookies (they might all be used for advertising or collect your preference to be sold to the highest bidder, though, but most likely they will be).

If you want to have even more control over which third parties can collect your data (even outside this website), please visit this website.

fr,DSID,IDE,uuid
fr
DSID,IDE
IDE
uuid