The Freshest Magento 2 Installation

The starting point for exploring the broad advantages and capabilities of Magento 2 is to download and install the platform.

Magento 2 Installation

Despite the awesome functionality Magento 2 is harder to install than the previous version of software. This necessitated the emergence of multiple installation guides across the Internet. But, most of them point at the manual way of installation, or cast a lot of console spells to install different server-side software, or just loose their relevance gradually.

On the other hand, there is a bunch of ready Magento 2 stores installed in online demos, but most of them are also outdated. Besides, in this case you can’t play around with files, command-line scripts, tests, etc.

Rapid obsolescence is pretty natural since Magento 2 is still in Beta and the code is subject to change until the GA release. Nevertheless, our ultimate goal is to overcome this obstacle and always have available a fresh Magento 2 version.

Below we share, we believe, a great way to install the latest Magento 2 any time you follow this guide. The solution uses Vagrant and Puppet to setup a full-featured Ubuntu box with Magento2 inside. All you need is to install VirtualBox and Vagrant, launch a couple of commands, and enjoy the freshest M2 already running.

Magento 2 Installation

Vagrant Configuration to Run Magento 2

This Vagrant configuration sets up the required environment and installs the latest available Magento 2 running on Ubuntu 14.04.3 LTS (Trusty Tahr).

Box Contents

  • Ubuntu 14.04.3 LTS (Trusty Tahr);
  • Apache 2.4 with mods enabled;
  • MySQL 5.6;
  • PHP 5.5.9 with all the extensions required for Magento 2;
  • Composer;
  • Git.

Installation

1. Install VirtualBox;
2. Install Vagrant;
3. Install the vagrant-puppet-install plugin by executing vagrant plugin install vagrant-puppet-install;
4. Download/clone and change the directory of this repository to its root;
5. [Optional] Configure variables inside Vagrantfilelike: port, hostname, docroot, etc.;
6. Run vagrant up and give it some time to install all the stuff for you. This will automatically download and configure the box and install all required software;
7. Edit your host files (/etc/hosts on OSX/Linux, Windows\System32\Drivers\etc\hosts on Windows) and add the line 127.0.0.1 magento2.dev. If you changed the hostname in Vagrantfile, be sure to replace magento2.dev with it.
8. When Vagrant will complete the installation, open http://magento2.dev:7654 in your browser

Why

This method of installation has several obvious advantages over the other ways:

  • You don’t mess up your PC with web servers or a database server, etc. All is under the hood of the Vagrant box;
  • It doesn’t require configured remote hosting;
  • We used Puppet inside, so it can be easily customized, extended and contributed by the community;
  • Most of PHP IDEs come with the perfect Vagrant integration;
  • It takes the latest Magento 2.
  • This configuration can be easily adapted to your needs, if you are an extension developer or building your own store.

FAQ

You may ask any questions regarding the installation just here in the comments below or you can enter this project on BitBucket.

  • Run vagrant provision, if you change something in the Vagrant/Puppet configuration;
  • Run vagrant reload to reboot your box;
  • Run vagrant destroy to remove the box completely;
  • Run vagrant ssh to start a SSH session;
  • If vagrant plugin install vagrant-puppet-install fails to run, just re-run it again, as it is a known issue for some Vagrant plugins;
  • Report any issues on the installation.

Conclusion

This is how we see a good way of Magento 2 installation, but we welcome other smart tips and valuable contributions to the process. Feel free to add them in the comments below or directly on BitBucket.

17 Comments

Comunidade Magento

about 2 years ago

Dears Srs, First, congratulations for this tutorial. I need others install Magento 2 in /var/www I need see all folder in /var/www I edited Vagrantfile for magento_docroot = '/var/www' http://imgur.com/fFjqNZI But persist load install default in /var/www/magento http://imgur.com/RAfSv6l How to install and load new installations of Magento 2 in this box ?

Reply

Dmitry Shatkov

about 2 years ago

Seems you have changed magento_docroot after the «vagrant up» run.

You should rather:

1. delete box completely with «vagrant destroy», change magento_docroot to /var/www and run «vagrant up» one more time

2. login to the box with «vagrant ssh», delete /var/www folder completely, delete mysql database «magento», then logout and run «vagrant provision»

The fastest way to install a new M2 instance is to simply launch other box instance in other folder.

However if you wish to install new M2 instances in the existing box, you can do this with Composer:

0. login to vagrant box using «vagrant ssh» and obtain superuser permissions with «sudo su»

1. git clone https://github.com/magento/magento2.git $magento_docroot and cange directory to $magento_docroot

2. create mysql database

3. /usr/bin/php -f bin/magento setup:install --base-url=http://$hostname:$port/ --backend-frontname=admin --db-host=localhost --db-name=$magento_db_name --db-user=$magento_db_user --db-password=$magento_db_pass --admin-firstname=John --admin-lastname=Doe --admin-email=admin@example.com --admin-user=$magento_admin_user --admin-password=$magento_admin_password --language=en_US --currency=USD --timezone=America/Chicago fill in variables starting with $

4. In the new magento docroot launch /usr/bin/php bin/magento setup:static-content:deploy to compile static content

5. finally do chown vagrant:vagrant -R $magento_docroot to grant required permissions

Alternatively, you can edit puppet/manifests/default.pp file to setup M2 instances you need and run «vagrant provision"

Reply

Comunidade Magento

about 2 years ago

Hello Dmitry, http://imgur.com/gXtDdwX - now is possible see all folders in /var/www - perfect http://imgur.com/fCEvtLn - install new Magento 2 in var/www - perfect http://imgur.com/YPyW4q4 - 404 not found when clicked in any link. http://imgur.com/ihCS97L - admin error. Return this when try run vagrant provision. http://www.heypasteit.com/clip/289B Thanks!!!

Reply

Dmitry Shatkov

about 2 years ago

In puppet/manifests/default.pp find the string exec { 'Magento setup wizard': cwd => $magento_docroot, timeout => 1800, command => "/usr/bin/php -f bin/magento setup:install --base-url=http://$hostname:$port/ --backend-frontname=admin --db-host=localhost --db-name=$magento_db_name --db-user=$magento_db_user --db-password=$magento_db_pass --admin-firstname=John --admin-lastname=Doe --admin-email=admin@example.com --admin-user=$magento_admin_user --admin-password=$magento_admin_password --language=en_US --currency=USD --timezone=America/Chicago" }-> Here you see the long command installing Magento. Your target is --base-url param It is constructed with http://$hostname:$port/ You must add path here(like http://$hostname:$port/your_magento/path) to install it in subfolder.

Reply

HRR

about 2 years ago

Hi there, Maybe a stupid question, but where is 'this' repository (Step 4)? Thanks, HRR

Reply

Dmitry Shatkov

about 2 years ago

Hi, here is the link https://bitbucket.org/aheadworks/vagrant-magento2

Reply

Comunidade Magento

about 2 years ago

Hello Dmitry, How to access in Windows the folder /var/www/magento in box Vagrant? Thanks!!!

Reply

Jacco

about 2 years ago

Tried this step by step but it kicks a error. I am running virtualbox 4.3 on a linux mint laptop kernel 4.3 vagrant up Bringing machine 'default' up with 'virtualbox' provider... There are errors in the configuration of this machine. Please fix the following errors and try again: vm: * The box 'puppetlabs/ubuntu-14.04-64-puppet' could not be found.

Reply

Jacco

about 2 years ago

Ok, downloaded the latest vagrant from the internet. Apparently the one in the repo's is too old

Reply

Jacco

about 2 years ago

Next step, magento2 is up and running. Go to the frontend, see the empty CMS home page. so lets try the backend: http://magento2.dev:7654/admin http://magento2.dev:7654/index.php/admin 404 not found According to the config file, that's what it should be: command => "/usr/bin/php -f bin/magento setup:install --base-url=http://$hostname:$port/ --backend-frontname=admin --db-host=localhost --db-name=$magento_db_name --db-user=$magento_db_user --db-password=$magento_db_pass --admin-firstname=John --admin-lastname=Doe --admin-email=admin@example.com --admin-user=$magento_admin_user --admin-password=$magento_admin_password --language=en_US --currency=USD --timezone=America/Chicago"

Reply

jacco

about 2 years ago

Does anybody know how to access the backend? I can't get into it

Reply

Ahir Hemant

about 1 year ago

Hello, I have just install magento2 with sample data, front is working fine but in admin area i am not able to open any menu it has # link at the end...So please give me solution, also when i remove pub/static content , i lost my admin and front css so it will look like without css, kindly help. Thanks

Reply

Syed Kazimi

about 1 year ago

Hi, I followed the tutorial. When accessing :7654 the page says "Magento supports PHP 5.5.22 or later. Please read Magento System Requirements. ". When I ssh into vagrant, and type "mysql --verion" (without commas), it is telling me "mysql Ver 14.14 Distrib 5.6.30, for debian-linux-gnu (x86_64) using EditLine wrapper " So, mysql version is 5.6, so what can be the problem.

Reply

Dmitry Shatkov

about 1 year ago

Thank you for the notification. We know this issue and our team is currently working on it.

Reply

Michael Sables

about 12 months ago

I am having same issue. Magento supports PHP 5.5.22 or later. Please read Magento System Requirements. Has this been fixed yet?

Reply

Edgar

about 9 months ago

Hello, is this still working? PHP 5.5.9 is not the version Magento 2 needs. Are you going to upgrade the Box?

Reply

Dmitry Shatkov

about 9 months ago

Yes, we are still going to update it. But, it may take several days or more to resolve some related issues.

Reply

Leave a Comment

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked