How to install Magento 2 on your hosting

Time to Read: 30 minutesDifficulty Level: Intermediate
Tools Needed: access to your hosting control panel (Plesk)Last Updated: 23/10/2017

Install Magento 2

This guide shows you how to install Magento 2 on your hosting. On the other hand, if you would like us to install Magento 2 for you then we’ll be happy to provide you with a quote for the work.

Let’s get started:

Magento 2 PHP Hosting Requirements
Using Installatron
Configure SSH access
Adding Crons
Securing Magento 2

Magento 2 PHP Hosting Requirements

1) Create your domain in Plesk by adding a new subscription and select it from the Domains option in the left-hand sidebar.

2) Make sure you’re using PHP 7.0.25 or 7.1.11 for your domain. We provide multiple PHP versions in your control panel, so it’s important you select the right one, otherwise you’ll have issues. Click the PHP Settings tool in your Domains dashboard in Plesk.

3) Select PHP Support then pick either PHP version 7.0.25 or 7.1.11 from the drop-down menu.

4) You will also need to update the value for open_basedir in this menu. You’ll find open_basedir under Common settings. Edit it so that it reads as follows:

{WEBSPACEROOT}{/}{:}{TMP}{/}{:}/etc/pki

Now scroll to the bottom of the page and select OK.

Using Installatron

Now onto installation. Using the Installatron 1-click installer is the quickest way to get up and running. Browse to Installatron Application installer in the left-hand sidebar of your hosting control panel.

Select Applications Browser then enter Magento into the search box and hit enter.

You can then select Install this Application

You’ll then need to fill in the relevant domain from the drop-down menu. Careful: this field may automatically select one of your domains and it may not be where you want your Magento 2 installation! You can choose whether or not you would like your Magento store to use HTTPS by default (although you’ll need to ensure you have a SSL in place for a HTTPS connection to the site to work). You can also specify a subdirectory for your store to reside at – in this example, I’ve chosen to install my new Magento store at magento2.com/shop.

You can then select which version of Magento you require. The most recent version available should be auto-selected (Magento 2.2.1 in this example).

You can also choose whether you want to install Magento 2 with or without the sample data. In this example, we’ve decided to use a clean Magento install and add our own products later.

Next it’s time to specify your admin username, password and associated email address. Installatron will automatically generate a random complex password for you but you’ll need to make sure you record these for use later on.

Next, click on Install.

Now sit back and watch Installatron do its work! It’s about time for a coffee anyway, isn’t it?

All done! Before clicking away from this page, note the 2nd URL: that’s your Magento login URL so you’ll want to bookmark it and maybe add to your password management tool too. To log into our example shop, we would need to browse to the following URL:

http://www.magento2.com/shop/index.php/s3j3olkp


If you do lose this URL, you can find the path you’ll need from the env.php file which resides at httpdocs/app/etc (assuming you didn’t specify a subdirectory for installing Magento 2 like I have in this example). The code you’ll want is directly after the line of code containing ’frontName’ =>.

Configure SSH access

The next step is to configure SSH access for your Magento store. This is necessary for the crons we’ll set up soon, but also required if you’re going to take advantage of Magento 2’s powerful command line interface.

Browse back to your domain in your Plesk control panel, then select the Web Hosting Access tool.

From the drop-down menu for Access to the server over SSH, change the setting from Forbidden to /bin/bash.

Click on OK to confirm the change.

As you may have noticed, other shells are available from the drop-down menu. There’s nothing wrong with using these for other sites if you prefer, but you’ll need the the bash shell specifically for the crons Magento 2 requires.

Now you’re ready to add cron jobs for your Magento 2 site.

Adding Crons

​Select the Scheduled Tasks menu from the right-hand sidebar. A Scheduled Task is simply Plesk’s term for a cron job.

Click on the Add Task button to create a new scheduled task.

The default setting will be to Run a command. There’s no need to change this so enter the following into the Command field: /opt/plesk/php/7.1/bin/php -d disable_functions=’’ -d allow_url_fopen=0 /var/www/vhosts/your-domain.com/httpdocs/bin/magento cron:run | sed ‘/Ran jobs by schedule/d’ >> /var/www/vhosts/your-domain.com/httpdocs/var/log/magento.cron.log

Please note that this command will need altering to specify a different version of PHP if you’re using it. You should also replace any instances of your-domain.com with your actual domain name. This command assumes that you’ve installed Magento to your web root folder (ie: httpdocs) and not into a sub-directory. In this example, I have updated my command as follows because my Magento was installed in the /shop sub-directory:

/opt/plesk/php/7.1/bin/php -d disable_functions=’’ -d allow_url_fopen=0 /var/www/vhosts/magento2.com/httpdocs/shop/bin/magento cron:run | sed ‘/Ran jobs by schedule/d’ >> /var/www/vhosts/magento2.com/httpdocs/shop/var/log/magento.cron.log

Next select the drop-down menu for Run to update Daily to Cron style. Magento advise that these crons should run daily, every minute of the day, so enter the following:

* * * * *


You can then test your cron by selecting Run Now or just click OK to finish adding the cron.

In the next screen, you should be able to see the cron you’ve just added. You can then click the Add Task button again and repeat the process to create the following 2 crons:

/opt/plesk/php/7.1/bin/php -d disable_functions=’’ -d memory_limit=768M /var/www/vhosts/your-domain.com/httpdocs/bin/magento setup:cron:run >> /var/www/vhosts/your-domain.com/httpdocs/var/log/setup.cron.log

/opt/plesk/php/7.1/bin/php /var/www/vhosts/your-domain.com/httpdocs/update/cron.php >> /var/www/vhosts/your-domain.com/httpdocs/var/log/update.cron.log

Again, you’ll need to update these commands to specify your domain name, the path to your Magento install (if you’ve used a subdirectory) and your desired PHP version if you’re not using PHP 7.1. For example, the crons I’ve created for my test store are as follows:

You should now have 3 similar crons created for your Magento store.

Securing Magento 2

The final step is now to properly secure your Magento 2 installation. Magento 2 has a great security feature whereby all files which are required to be web-accessible are in the /pub folder. The files in this folder are just the files needed to present the store to users. By making the /pub folder the webroot for your domain’s webspace, you massively reduce the surface area for potential attacks against your Magento install. To do this, log into your Plesk control panel. Browse to your domain then select the Hosting Settings tool. From here you can update your document root to httpdocs/pub or the relevant subdirectory. In this example I’m setting mine to httpdocs/shop/pub.

You’ll need to select OK to confirm the change you’ve made. Please note that this is only one step in securing your store: it’s a great start but should not be your one and only security concern!

Need more help? Lets talk

Or call 0800 033 7074