How To Install The Magento2 Beta

The Magento 2 Beta is out! This version is a little more difficult to install than previous versions of Magento. These instructions may not work for everyone but I was able to successfully install Magento2 and the sample data on my local Ubuntu dev environment and on my sandbox located at: http://m2.seanbreeden.com/.

I adapted some of the instructions from the blog post for installing Magento2 from Magenticians.com. Their instructions didn’t work for my exact configuration so my hope is that these modified steps will save some time for anyone with a setup similar to mine.

There’s some system requirements that you’ll need to meet prior to attempting to install Magento2. The complete list of them are here.

I don’t foresee anyone successfully installing this on a shared hosting environment unless it’s been configured with Magento2’s requirements in mind.

Here are my system specifications:

  • 5.6.21 MySQL Community Server
  • PHP 5.4.36 (cli) (built: Dec 24 2014 19:11:17)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
    with the ionCube PHP Loader v4.6.1, Copyright (c) 2002-2014, by ionCube Ltd.
  • 4GB RAM
  • CENTOS 6.6 x86_64 virtuozzo – server
  • WHM 11.46.1 (build 4)

With the sample data installed my total Magento2 install is 4.8G which includes the .git repo.

If you use WHM, you can upgrade your mysql to version 5.6 by going to System > Mysql Upgrade, then select Mysql 5.6. I used the “Unattended Upgrade” with no problems to move from Mysql 5.4 to Mysql 5.6.

Here are the steps that I used to get Magento2 installed.  The end result was a  Magento2 install complete with the Luma theme and Sample Data. Unless otherwise specified, all of these command should be run from the cli using SSH preferably with root/sudo access.

Installing Magento2

1. Log in to WHM and create a new hosting account, domain and mysql database. Be sure to assign the mysql user all of the rights to the database you’ve created.

2. Log in to SSH as root.

3. Install Composer.

curl -sS https://getcomposer.org/installer | php 

4. Make composer accessible from anywhere so you don’t have to use the full “php composer.phar” command to run it.

mv composer.phar /usr/local/bin/composer 

5. Change to the home folder for your newly created account. For demonstration purposes, I’ll be using my setup information.  My username for the account that I set up was m2seanbreeden. Substitute “m2seanbreeden” with your account username.

cd /home/m2seanbreeden/

6. Clone the Magento2 git repo.

git clone git@github.com:magento/magento2.git

6a (optional). I want to keep my Magento2 install up to date as the git repo is updated. I set up a symlink to make the magento2 folder that cloning the repo creates as my web root.

mv public_html public_html-BAK
ln -s magento2 public_html
chown m2seanbreeden:nobody public_html 

This backs up the original public_html that the system creates and adds a symlink to the magento2 folder called “public_html” so the web server can use it as the web root.  Finally, the chown sets the owner correctly to allow the web server to see the folder.

7. Run the Composer install.

cd public_html
composer install 

8. Fix all permissions.  If you’ve worked with Magento a while then this part should be familiar.

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

9. Modify permissions of folders that Magento2 requires. This part will be a little different than you remember from earlier versions of Magento since the file structure has changed a bit.

chmod -R 777 app/etc pub/media pub/static vendor

Notice that media is now a subfolder of “pub”.

10. Update your memory_limit! If this setting is too low then you’ll get some unusual problems with your install like freezing at 2% or 96% with no error messages. You can change this globally in WHM or just add the following line to the very top of public_html/index.php:

ini_set(“memory_limit”,”2048M”);

Also set this same line at the top of dev/tools/Magento/Tools/SampleData/install.php

I actually set mine to 4096M to be safe.

11. Install Magento2 from a web browser. There is a command-line option that I attempted first but for some reason I couldn’t get the Demo data to install later on. The web install worked great.

Simply load a web browser and navigate to your Magento2 install. Follow the Setup Wizard until Magento2 is installed.

Installing the Sample Data

Installing the sample data and using the Luma Theme will provide a great jump-start to get familiar with Magento2.

1. Update composer.json to include the new Sample Data repository. You don’t have to directly edit this file.  Instead, run the following command to complete this action:

composer config repositories.magento composer http://packages.magento.com

2. Next, run this to add the sample data and sample data media packages:

composer require magento/sample-data:0.42.0.beta1 magento/sample-data-media:0.42.0-beta1 –dev

3. To install the sample data:

php dev/tools/Magento/Tools/SampleData/install.php –admin_username=admin

“admin” will be the name of the admin user that you defined during the installation.

The install for this takes a while so be patient. If you interrupt any part of this or it crashes it’s best to start out with a clean database from step 1.

Deploying the Luma Theme

I still couldn’t see the Luma theme after I completed all of the steps above. My Magento2 install theme files were all 404s and the page was just plain text with no graphics. If you experience this then run this command from web root:

php dev/tools/Magento/Tools/View/deploy.php

After everything compiles flush the system cache with this command:

php dev/shell/cache.php –flush

All done!

Congratulations!  You should now see your Magento2 install with the Sample Data and Luma theme!

To see the end result of my install you can check it out here: http://m2.seanbreeden.com/

Thank you to Magenticians.com for their instructions for installing Magento2. (http://magenticians.com/installing-magento-2-composer). It didn’t work out of the box with my configuration but it definitely helped me fill in some blanks!