Installing Magento 2 on Hypernode

in Magento Tags: MagentoMagento 2Magento2

Hypernode trial plans come with a default Magento 1 or 2 installation! You only need this page if you are upgrading from Magento 1, or if you want to re-install Magento 2.

Magento 2 requires a Magento Grow hosting plan or bigger. If you have Magento Start, upgrade to Magento Grow to install Magento 2. Want to install Magento 1 instead?

Installing Magento 2 will take only 5-10 minutes (add 15 minutes if you want the sample data).

Upgrade your php version

Before installing magento, change your php version to php7.

Some vendor libraries are not compatible with older php version anymore, causing errors during the installation.
Therefor you must first change your php version to php7 before starting the Magento 2 installation.

Remove existing Magento 1 installation (if any)

This is obviously only required if you have a previous Magento 1 installation. Log in to your Hypernode and run this command:

magerun --root-dir=/data/web/public uninstall --installationFolder=/data/web/public --force

This will delete the default database (such as shop_preinstalled_magento), and recursively delete the /data/web/public directory. Any instances of Magento installed in other directories will not be touched.

Activate Magento 2 mode

Hypernode will activate all kinds of Magento 2 cleverness when you activate M2 mode. This happens when you put a file in /data/web/nginx/magento2.flag:

touch ~/nginx/magento2.flag

Install Magento 2 using the command line

1. Download and unzip the latest release to /data/web/magento2:

mkdir ~/magento2
cd ~/magento2
wget -qO- https://magento.mirror.hypernode.com/releases/magento2-latest.tar.gz | tar xfz -

2. Create a database (In this example, we named the database ‘magento2’, but you can name it however you like):

echo "create database magento2" | mysql

3. Enable the Magento 2 management tool:

chmod 755 bin/magento

4. Almost done! Look up your database credentials

cat ~/.my.cnf

5. Fill in the user, hostname and password in the following command and you are ready to install Magento 2:

bin/magento setup:install --db-host=[HOSTNAME] --db-name=[DATABASE] --db-user=app --db-password=[DATABASE_PASSWORD] --admin-firstname=[YOURFIRSTNAME] --admin-lastname=[YOURSURNAME] --admin-user=[ADMINNAME] --admin-password=[ADMINPASSWORD] --admin-email=[YOUR@EMAIL.COM] --base-url=[http://YOUR.HYPERNODE.IO] --language=[en_US] --timezone=[Europe/Berlin] --currency=[EUR] --use-rewrites=1

6. Enable secure documentroot

cd ~
rm -rf /data/web/public
mkdir /data/web/public
ln -fs /data/web/magento2/pub/* public

7. Build static assets (CSS & JS)

cd ~/magento2
bin/magento setup:static-content:deploy

Alternatively you can deploy only the static content for a single theme:

bin/magento setup:static-content:deploy --theme=Magento/luma en_US

Or for a single language:

bin/magento setup:static-content:deploy --language=en_US

A secure, random Magento admin URL will be created for you and printed. Bookmark it for future access.

Congratulations, Magento 2 is installed on your Hypernode!

Configure your Magento 2 cron

After installing Magento, configure your cron by adding these scripts to your crontab file:

* * * * * flock -n ~/.cron.lock php /data/web/magento2/bin/magento cron:run
* * * * * flock -n ~/.update-cron.lock php /data/web/magento2/update/cron.php
* * * * * flock -n ~/.setup-cron.lock php /data/web/magento2/bin/magento setup:cron:run

Want to install sample data too?

Login at your My Magento account. Go Connect => Developer => Secure keys. Create a new key. Copy your public key (username) and private key (password).

cd ~/magento2
composer update

enter your public and private key when asked for user and password
when asked to save to a location, the default is fine

ln -fs ~/.composer/auth.json var/composer_home/

this is required due to a bug: https://github.com/magento/magento2/issues/2523

bin/magento sampledata:deploy

This action will take about 10-15 minutes

bin/magento setup:upgrade

Troubleshooting

  • I’m getting the error:
    PHP Parse error: syntax error, unexpected '.' in /data/web/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93
    This is caused by the php version. Upgrade from php5 to php7 as not all vendor libraries are php5 compatible anymore.

  • I’m getting out-of-memory errors:

    • If you are running on a Start plan: Upgrade to a bigger hypernode with more memory available.
    • If this happens while you are running a setup:static-content:deploy: Try deploying static content per language or per theme rather then all at once.

2