As Magento2 is one of the most used ecommerce solutions, on this planet, there are a lot of ways to run it. A modern, full blown, production ready, Magento stack will probably consists out of:
varnish, redis, nginx, php7-fpm, php7-cli, mysql and magento2 community edition (ce) or magento2 enterprise edition (ee). For development purposes you can remove some of the components as you probably don’t want a lot of caching; except when you want to test that kind of stuff. A normal enterprise environment would do that kind of tests in their acceptance anyway.
If you are developing on Mac OS; you will roughly have three options: 1) Run Magento inside a linux VM (or use vagrant)
2) Dockerize it and use docker on the mac 3) Install it locally
This blog post will focus on the first option: using Magento with Vagrant. The big advantage is that the resulting vagrant box will probably closely mimc an actual one server setup of magento; including varnish and redis if desired. You will need a couple of requisites: A Magento merchant account and a github account. So, let’s go.
There are rougly 2 ways to accomodate a nice Vagrant setup, with and without Ansible. To keep complexity low this post only handles a setup without using Ansible to provision the vagrant box.
Most of the stuff you’ll need is described in the README of the excellent magento2-vagrant-for-developers github project. Follow the installation instruction to get a Vagrant box with php7 and magento 2.2 dev.
You can just follow the instructions. You’ll need a Magento Marketplace account and a personal Github token to install packages via Composer. In fact this is optional but if you are going to use the Magento for development purposes you’ll probably want to install packages from the Magento Marketplace.
Create an account here then navigate to: My account => Marketplace => My Access Keys => Magento2 => Create A New Access Key.
Now you can copy/paste the public key to auth.json as the repo.magento.com username and the private key to password.
Composer will use the github API for certain operations. To ensure a problem free setup, you can generate a token that composer will use to authenticate yourself with your github credentials.
Login in to your github account and navigate to: https://github.com/settings/profile => Personal access tokens => Generate new token
After submitting the form you can copy/paste the token as the github.com key in auth.json
The complete auth.json will look like this:
Watch the output as it will generate a random hostname suffix which you will need to access your store:
Access storefront at http://magento2.vagrant Access admin panel at http://magento2.vagrant/admin/ Magento admin user/password: admin/123123q Rabbit MQ control panel: http://magento2.vagrant:15672, credentials guest/guest
It will ask for a password once; this is the password of your user on Mac OS.
You can now also fire up PHPStorm and point it to your vagrant-magento folder + configure a remote PHP interpreter. Please make sure to read the docs on https://github.com/paliarush/magento2-vagrant-for-developers
Another way of getting a Magento2 up and running in Vagrant uses vagrant to spin up a Linux VM, then it installs Ansible on the VM and uses it to execute an Ansible playbook, via localhost, to install a Magento environment.
You can find the github repo here: https://github.com/cedricblondeau/magento2-ansible-vagrant
It will install a mostly similar stack:
PHP7 + Nginx + Redis (sessions, full page cache, frontend cache), MariaDB 10.0 + Magento2
The nice thing about this setup is the fact that you could quite easily use it to deploy, and re-deploy, an simple Magento2 shop to a Digital Ocean VM with Ansible.
Configuration is done by setting values in an Ansible variabels file. You’ll need a Magento Market store account. Make sure that you use an admin password of at least 7 characters.
Now access your store at http://192.168.6.6
Quick Links
Legal Stuff