I have been using Vagrant VVV for development on local for a long while now; havinng moved from XAMPP and PHPmyadmin for as long as I’ve been doing this stuff, moving to Vagrant presented me with a very real fear that I wouldn’t be able to easily setup local installs of live sites. With XAMPP I had always did a find & repace using the Search and Replace DB script, after importing the DB to the the local/development servers.
It wasn’t perfect but served my needs for any db under 50MB. Sadly as I have been tasked with older installs and larger DBs that restriction has become problematic. Fortunately Vagrant once again steps in to save my butt.
This is mostly a command line process but I promise it’s pretty basic, much faster than my previous mostly manual solution, and isn’t restricted to the PHPmyadmin file size limits. These steps while specific to Vagrant make use of the WP-CLI which is not specific to Vagrant. You could probably do this with XAMPP/MAMP and can definietly do this on your server if you set it up proper.
WARNING
If you are cloning a live site make sure you update your local wp-config.php file accordingly. Just copy the settings that Vagrant setup for you with the wp install.
DB IMPORT IN VAGRANT
This assumes you installed vagrant at the default location of vagrant-local
- Rename db
Make sure that the db you will be importing is the same name as the db you will be importing into. So if your local site has a database name of EXAMPLE.sql you need to make sure that the db you will be imported also has the name of EXAMPLE.sql
- Move db
Make a copy of the db you will be importing and move it to the root directory of the site you will be importing into./vagrant-local/www/EXAMPLE/ - ssh into vagrant
cd vagrant-localvagrant ssh - cd to site
cd /srv/www/EXAMPLE
- Import db
wp db import DATABASE.sql - Search and Replace (optional)If you need to do a search and replace run the following command. It handles serialized data appropriately so you don’t bugger up your site.wp search-replace ‘http://example.com’ ‘http://example.dev’
- Celebrate 🎉
Extra: Commands that start with wp make use of the WP-CLI which comes set up with vagrant. See http://wp-cli.org for more info and available commands.Vagrant does support PHPmyadmin at vvv.dev but the upload limit is actually lower than MAMP. This limit can be changed in your PHP.ini file but I really don’t think it’s worth doing with how much easier the command line method is.
What tools do you use for your development environments? Do you have any favourites?