You're going to the Magento Bugathon in Los Angeles? Or joining from the Magento Hackathon in Zuerich? Planning to go to the San Francisco Hackathon in April? Or to any other Hackathon? Or just hanging around with your friends or collegues hacking some cool Magento stuff?
Then you'll need a fresh Magento instance! In this blog post I'll show you how to create a new Magento instance in less than a minute from any source!
This blog post will not cover how to install a LAMP stack. I'm assuming you already have an existing Linux environment with following components:
- Apache (or even better: nginx) and a configured virtual host
- PHP (or even better: php-fpm), including all needed module (check the system requirements)
- MySQL and an empty database including a database user (see snippet)
Btw, setting up a VirtualBox machine that comes with this software stack and any other required configuration using Chef and Vagrant is even more fun. (But is not covered in this article, and well... might take a little longer than 60 seconds :)
Let's get started
n98-magerun is an awesome tool that will not only help you to set up your Magento instance. If you don't know that tool yet you should definitely check it out.
n98-magerun can install a Magento instance from different sources. By default it comes with a pre-packaged configuration the recent Magento Community editions, some alternative sources and even experimental support for Magento 2!
The great thing about this tool is, that it allows you to add custom configuration for additional sources. The prepackaged configuration can be found here (this file is part of the phar archive). But n98-magerun will check some other locations for additional configuration. Read more about this here.
Magento has provided a git repository on GitHub with the latest Magento code (that btw, will be the basis for the upcoming releases CE 1.8 and EE 1.13).
By adding a configuration file with the following content, n98-magerun will install Magento using the sources from that git repository. I chose to add this configuration to
commands: N98\Magento\Command\Installer\InstallCommand: magento-packages: - name: magento-bugathon version: dev-master source: url: https://github.com/magento/bugathon_march_2013.git type: git reference: master extra: sample-data: sample-data-18.104.22.168 installation: defaults: currency: USD locale: en_US timezone: America/Los_Angeles use_secure: no use_rewrites: yes session_save: files admin_username: admin admin_firstname: John admin_lastname: Doe admin_password: password123 admin_frontname: admin admin_email: email@example.com
You can download n98-magerun (see official documentation) and place it in your current folder or you can move it to a folder in your path so that you'll be able to access it from everywhere:
sudo curl -o /usr/bin/n98-magerun.phar https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar sudo chmod +x /usr/bin/n98-magerun.phar
Now go to the parent directory of the webroot you configured in Apache (or Nginx) and install Magento by executing this command and following the instructions:
If you have the custom configuration file in place you should see the option "magento-bugathon" that is configured to get the Magento sources from the repository that was created for the hackathon.
Magento will install now and you can even chose to have the sample data included!
After the installation n98-magerun will automatically trigger the indexers and will even perform some basic tests to verify that your new Magento instance is working correctly:
In case there is no
.htaccess file in the Magento root folder (not sure if this is a bug, but it was not there in my case) copy over the
.htaccess.sample file and check the file in case you need some modifications...
Also you might want to install modman:
sudo curl -o /usr/bin/modman https://raw.github.com/colinmollenhour/modman/master/modman sudo chmod +x /usr/bin/modman
n98-magerun is an awesome tool and even if you screw up your Magento instance during the Hackathon and you want to start from scratch (or if you need multiple Magento versions next to each other to test your module in those different versions) n98-magerun will help you to get this task done quickly and efficient. Less time spent on the boring stuff gives you more time to spend on the interesting things :)