STORM servers support Magento 2 out of the box so you don’t need to worry about installing any prerequisite software on the server or configuring your vhosts. STORM can take care of this for you making the setup quick and easy. Here are some handy tips to help you get started with running Magento 2 on STORM.
Adding a Magento 2 site to STORM
You can add a new Magento 2 site to your STORM server by clicking “Websites” and then “Add Website” from your server’s dashboard.
When adding a website to STORM that’s running Magento 2 it’s very important to select the CMS from the application drop down menu regardless of whether you are setting up a new site from scratch, or if you are moving an existing Magento 2 site to the server. This will ensure that that hosting is set up correctly for running Magento 2.
If you are setting up a new site and would like STORM to install the application for you, select Magento 2 from the drop down menu and click “Install Application”.
If you are looking to upload an existing Magento 2 site to the server, again select Magento 2 from the drop down menu but just make sure that “Install Application” is not selected.
By selecting the application from the drop down menu, this will mean that STORM will set up the following for you:
- Correct folder structure for Magento 2
- PHP Limits specifically tuned for Magento 2
- Nginx config
- Scheduled Tasks (Cron Jobs)
Please note that it is not possible to select the application after the site has been added to STORM. It has to be done at the point of adding the site to STORM.
Scheduled tasks (Cron Jobs)
There are three cron jobs that need to be set up in order for Magento 2 to function correctly. These get set up automatically for you if have selected Magento 2 as the application when adding the site to STORM.
You can check these have been set up correctly in the website dashboard under “Scheduled Tasks”
The logs for each of these cron jobs can be located inside your applications log folder. For example:
Here is some further reading on how the cron jobs for Magento 2 work:
A common problem people often run into when using Magento 2 is incorrect file permissions on the web files for the site. These often come in the form of error messages either on the front end of the website or in the admin backend.
“Permission denied in /home/storm/sites/magento2test-com/var/generated/File.php on line 100”
With STORM it’s very easy to remedy errors such as the above from within STORM itself. To reset your websites file permissions, click on “Configuration” in your websites dashboard and then click the “Reset Permissions” button. This will reset the permissions to the Magento 2 recommended defaults.
Magento have reworked the folder structure for Magento 2 so it’s quite different from the folder structure that Magento 1 used. The main change that catches a lot of people out is that the document root has changed to the ”pub” folder.
Magento 2’s application files now live outside of the document root for security purposes. So the web root is now a folder inside the application itself.
If you selected Magento 2 as your application when you added the site to the server, the web server configuration is all set up for you with the correct document root in place.
Here’s an example to explain this further. I have added the site magento2test.com to my STORM server.
- My Magento 2 files are located in: /home/storm/sites/magento2test-com/
- And my websites document root is: /home/storm/sites/magento2test-com/pub
Here is what the files should look like:
As you can see from the screenshot. All of the Magento 2 application files are alongside the document root. Only files that are publically accessible are in the “pub” folder.
Amasty have a really good breakdown of the other folders, here’s a link for some further info:
Using the Magento 2 CLI
Magento 2 now has a command-line interface for managing many important functions of the application such as:
- Compiling your websites static content
- Enabling the Magento 2 caching
- Changing your Magento 2 websites mode.
Unlike Magento 1, Magento 2 requires a level of familiarity with the Linux command line in order to use the application properly.
Before you run any commands on your Magento 2 site you will need to connect via SSH to the server. Every website that gets added to STORM will have its own website level SSH user and it’s important to use this user to run your commands to avoid issues with permissions.
You’ll need to get add your IP to the servers allowed IP list before you can connect via SSH. This can be done in the server’s main dashboard by clicking on Security and then by clicking the “Add record” button.
Once you have done this, you can find your SSH login details in your website dashboard under the “SSH” tab. We have a more in-depth, step by step guide for getting connected via SSH here if you need it: https://support.nimbushosting.co.uk/support/solutions/articles/36000022440-ssh-access
Now that you are connected via SSH as the websites SSH user you can use any of your Magento 2 commands safely.
Here’s an example of me clearing the cache on my test Magento 2 installation:
For more information on specific Magento 2 CLI commands, please see the following link:
Magento 2 Modes
Another big difference between Magento 1 and Magento 2 is the introduction of different website modes. Magento 2 has three different modes that you will need to set the site to depending on the situation. These are Default, Developer and Production.
Default Mode is the mode the site will be in out of the box straight after you have installed the application. It’s designed for testing the application on your hosting environment. If Magento 2 is working properly on the server, you should switch from this mode to one of the other modes.
Developer Mode, as the name specifies is the mode your application should be in when you are working and developing your Magento 2 site. This mode will be much slower than production as all the built in caching for Magento 2 will be disabled. Extra debugging features and logging features are enabled when in Developer Mode as well.
Production Mode is the mode your Magento 2 site should be in when development has been completed and it’s in a live production environment. When your Magento 2 application is in Production Mode it should be significantly quicker to load compared to the other 2 modes due to the caching being enabled. It also prevents any errors from being displayed to the end user.
Here’s some more detailed info about each of the modes:
Known Magento 2 Issues
- Invalid Form Key. Please refresh the page - If you see this error when trying to upload to the site and save a product it can be remedied by raising the max_input_vars php variable to 5000 in the php settings for the site.
- Server running out of disk space - There is a known issue with a specific version of Magento 2 (Version 2.2.6) that causes the servers “tmp” folder to fill up with multiple archive files (.tar files). A reboot of the server will clear the files however they will regenerate. The long term fix is to upgrade to a newer version of Magento 2.
Here’s the bug report of the issue:
Magento have their own extensive knowledgebase explaining everything you need to know about Magento 2 which can be found here: https://devdocs.magento.com/guides/v2.2/config-guide/bk-config-guide.html
Another great resource is the Amasty knowledgebase. Amasty has been a provider of many popular extensions for both Magento 1 and Magento 2 over the years and have a lot of useful documentation which can be found here: https://amasty.com/knowledge-base/topic-magento-related-questions.html