Local development

You can locally develop a WordPress site that is hosted at Presslabs by following a few easy steps. This will help you understand how to use Vagrant and the production file structure.

We’re offering Vagrant as a default tool for developers that need to work on the WordPress sites hosted on Presslabs.

What is Vagrant?

Vagrant is a tool that replicates a production environment to your local computer for development purposes. It’s simple, straightforward and works just on any platform: Mac, Windows and Linux.

How to Install and Configure Vagrant

There are a few easy steps to get a complete development setup on your local computer. Here they are:

Step 1

Download and install Vagrant and VirtualBox . Installing them is very easy and straightforward.

Step 2

Clone your site’s Git repository on your local computer. Got to the folder where you want to clone it and run from the terminal or command line:

git clone https://git.presslabs.net/username/site-name.git

You need to replace username and site-name with your username and the name of your site — as it’s defined in our systems. The full clone URLs are available on Gitea . After your run the command, you will need to introduce your Presslabs account credentials.

Step 3

We need to add WordPress on your local repo so that Vagrant can properly start the local copy of your site. WordPress will be cloned in the wordpress sub-folder of your cloned repository. All you have to do is to enter the cloned repo:

cd site-name

And then clone the sub-modules:

git submodule update --init

Step 4

You need to download your DB copy, from the Snapshot Sectionin our Managed Hosting Dashboard, as seen below. After you get the DB dump, just copy it inside the main folder of the Git repo — you’ll import it in the next steps.

Request a database snapshot from the Managed Hosting Dashboard

Step 5

Let’s start the virtual machine created by Vagrant. Type from inside the Git repo, using the command line or terminal:

vagrant up

This will start the Vagrant environment by spawning a virtual machine through VirtualBox. Please give it a few minutes for a full start.

Now you need to import the DB. For that you firstly need to connect to the Vagrant machine using SSH:

vagrant ssh

Then make yourself root by typing:

sudo -i

Check that you can see the SQL dump that you copied earlier by typing:

ls /vagrant/

In this folder you can actually access from the machine the entire Git repo, if needed. If the file is there, you need to start the MySQL command line by typing:


Select the WordPress database where you need to import your site’s DB by typing:

USE wordpress;

Now you’re ready for import, therefore run from the MySQL command line:

SOURCE /vagrant/mysql-dump-file-name.sql;

After the import is finished, check that you can see all the tables by typing:


Then disconnect from the SSH by pressing CTRL+D three times.

Step 6

Your environment is now ready to use and the only thing you have to do is to access it using your browser. Therefore point your browser to this address:


Step 7 (optional)

For a complete testing experience you might need to have some of the images stored in the uploads folder. You can download a media backup from the snapshots section or drop us an email at support@presslabs.com if you only need the last month of media files, for example. Then copy the files to the uploads folder of your Git repo. They’re added in the .gitignore file by default, therefore they won’t be committed to the Git repo after copying them over.

Step 8

When you have finished working with your Vagrant environment, it’s advisable to stop it, so it won’t consume your computer’s resources. You can do this by running from the Git folder:

vagrant halt

All set, happy coding!

How can I access logs in Vagrant?

The logs for the Vagrant instance are available in the /log/ folder of your site’s repo (/my-site-repo-folder/log/).

These are the files found there (their names are self explanatory):

  • nginx-access.log
  • nginx-error.log
  • php-access.log
  • php-error.log