As more and more shops switch to shiny new Magento2 webshops it’s handy to know how to spin up a 1.9 shop if customers ask for migration plans, or to have easy access to an environment that can be used to experiment with the magento environment itself.

To copy a customer site to a development laptop so you can start investigating it follow this plan:

  1. Get vagrant up and running:
    warning: you need vagrant guest-additions

    git clone git@github.com:klierik/simple-magento-vagrant.git
    cd simple-magento
    vagrant up
    
  2. Copy the shop + DB of the production server to your vagrant host:
    scp db.sql.bz2 webfolder.tgz vagrant@192.168.99.99

    pass: vagant
    Note: I expect a folder html in webfolder.tgz!

  3. Install DB + srcNote rest of steps occurs on vagrant host itself:
    ssh vagrant@192.168.99.99
    sudo su
    mysqladmin - u r00t drop magento
    mysqladmin -u root create magento
    bzip2 -d db.sql.bz2
    mv /var/www /var/www.old
    tar -xzvf webfolder.tgz /var/www
  4. Configure the production magento to be available under the new hostname of the vagrant box.
    mysql -u root
    UPDATE core_config_data SET value = 'http://simple-magento-vagrant.dev/' WHERE core_config_data.path = 'web/secure/base_url';
    UPDATE core_config_data SET value = 'http://simple-magento-vagrant.dev/' WHERE core_config_data.path = 'web/unsecure/base_url';
    DELETE FROM core_config_data WHERE path='web/cookie/cookie_domain';
    DELETE FROM core_config_data WHERE path='web/cookie/cookie_path';
    

    The site should now be fully operational @ http://simple-magento-vagrant.dev

  5. If you don’t have an admin account already get https://files.magerun.net/n98-magerun.phar
    scp n98-magerun.phar vagrant@192.168.99.99:
    chmod +x n98-magerun.phar
    sudo cp ./n98-magerun.phar /usr/local/bin/
    cd /var/www
    n98-magerun.phar admin:user:change-password admin
    

    This assumes an existing admin user: if you don’t have one you can create one for yourself:

    n98-magerun.phar admin:create admin admin@example.com admin Ad Min