We're offering Vagrant as the default tool for developers that need to work on the WordPress sites hosted on Presslabs.
Vagrant is a tool that replicates a production environment to your local computer for development purposes. It's simple, straightforward and just works on any platform: Mac, Windows and Linux.
There are a few very easy steps to get a complete development setup on your local computer. Here they are:
Clone the Git repository of your site on your local computer. Got to the folder where you want to clone it and run from the terminal or command line:
git clone email@example.com:site-name.git
Note You need to replace
site-name with the name of your site as it is defined in our systems. The full clone URL's are available in the Access section of our dashboard.
You can find more details about cloning the Git repos on our Access section.
We now 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:
and then clone the sub-modules:
git submodule update --init
Request a database dump from our support team by writing an e-mail to firstname.lastname@example.org. After you get the DB dump, just copy it inside the main folder of the Git repo. We'll import it in the next steps.
Let's start the virtual machine created by Vagrant. Type from inside the Git repo, using the command line or terminal:
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 first need to connect to the Vagrant machine using ssh:
Then make yourself root by typing:
Check that you can see the SQL dump that you copied earlier by typing:
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:
Now you're ready for import, therefore run from the mysql command line:
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.
Your environment is now ready to use and the only thing to do is to access it using your browser. Therefore point your browser to this address:
For a complete testing experience you might need to also have some of the images stored in the uploads folder. You can copy them from the live site using SFTP. Just fetch the last 2-3 months from the uploads folder and copy them 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.
When you have finished working with your Vagrant environment, it's advisable to stop it, so it won't eat your computer's resources. You can do this by running from the Git folder:
All set, happy coding!
The logs for the Vagrant instance are available in the
/log/ folder of the repo for your site (
These are the files found there (their names are self explanatory):