How To Set Up & Configure Server For Magento 2 & 1

- Magento 2, Magento tips & tricks

Magento server configuration

The following guide teaches how to set up and configure server for both Magento 2 and 1.X. Below, you will find a list of providers that offer cheap but quite powerful and reliable dedicated server solutions, discover how to install all-in-one web stack required by your Magento website (including Nginx, Apache, MariaDB, PHP 5.6, OPCache, and Redis), get a deep insight on the usage of Composer, Git, IonCube, XDebug & PHPUnit, Solr, Varnish, as well as Grunt and RabbitMQ on a server. Magento server configuration is a piece of cake!

'

Magento Server Configuration: Server Providers

There are a lot of providers that offer cheap and reliable server options optimized for Magento. Some companies already have dedicated servers which support Magento 2 requirements, while others are going to provide optimized solutions in the nearest future. Below, you can see the most prominent dedicated server options divided into regions.

  • USA. OVH provides dedicated enterprise servers for your Magento store starting from €69.99 per month. You can see a list of other available countries on the official website here: OVH dedicated enterprise servers

How To Set Up Server For Magento 2

  • Germany (EU). Hetzner offers Dedicated Root Server for your Magento 2 and 1.X at € 46.41 a month. For further information, visit the official website: Hetzner Dedicated Root Servers.

How To Configure Server For Magento 2

  • Netherlands (EU) & USA. EqServers has dedicated servers for your ecommerce store available in both USA and Netherlands starting from $79 per month. For further information, ask specialists from EqServers.com.

How To Set Up Server For Magento 2

These are the cheapest and at the same time powerful and reliable server options suitable for Magento. If you know other similar solutions, leave your thoughts in a comment field below the post. As for Magento server configuration at this stage, you should ask your provider to install a recent stable version of Debian or do it via server administration on your own.

Magento Server Configuration: All-In-One Web Stack

Now, it is necessary to install all-in-one web stack to set up and configure server for your Magento 2 or 1.X website. Pay attention to LEMP, LAMP, LNMP, and LNMPA stack installation script, which significantly improves the installation procedure. By using the script, you will enhance your Magento server with the help of PHP, Linux, MySQL, Apache, Nginx/Tengine, MariaDB/Percona, etc. It is highly recommended to use Nginx instead of Apache, since it provides better performance for your Magento website. To install all-in-one web stack on your Magento server, follow this link:

LEMP stack/LAMP stack/LNMP stack installation scripts

Alternatively, you can run several separate installations for all the aforementioned components, but it is more convenient to install everything as a single software block.

MariaDB Magento Configuration

How To Configure Server For Magento 2

After installing the aforementioned technology stack, it is necessary to tune some of its components. Let’s start with MariaDB – an enhanced replacement for MySQL.

Use the latest stable version of MariaDB and keep in mind that its configuration is among the most essential aspects of server side performance optimizations of your Magento 2 or 1.x website. Properly configured MariaDB provides performance bump up to 65%. Besides, MariaDB utilizes less resources than the average hardware provides. Thus, recommended settings for innodb_buffer_pool_size on a dedicated database server look as follows:

  • For 6 GB RAM – 5 GB;
  • For 12 GB RAM – 10 GB;
  • For 24 GB RAM – 18 GB.

In case of combined web and database servers, don’t use more that 50% or RAM. For instance, if there are 6 GB available, use 2-3 GB. For a dedicated database server it is recommended to utilize approximately 80%. Other vital MariaDB are listed in the following code field:

You can also configure your Magento server and its MariaDB parameters according to this Magento MySQL settings: Magento default mysql settings. Change variables according to the available amount of RAM.

PHP Magento Configuration

How To Set Up Server For Magento 2

As for PHP and server configuration for Magento 2 and 1.X, it is extremely important to install the newest PHP version. In case of Magento 1.x, it is PHP 5.6, in case of Magento 2 it can be the same version of the language or its next generation PHP 7. Everything depends on your project, skills, and available resources. Below, you can see what parameters to use with your php.ini file:

Besides, you should always check system requirements of Magento (Magento 2 System requirements; Magento 1.x System Requirements), because some vital PHP extensions are listed there.

Redis Magento Configuration

How To Configure Server For Magento 2

To configure Redis on a server for your Magento 2 of 1.x website, use the EPEL repository. You only have to install a single package and import the GPG key of the EPEL repository. Chances are,  the repository is already added to your server, so it’s highly recommended to use the yum repolist command to avoid unnecessary steps in your Redis Magento configuration.

Download a package that adds the aforementioned repository to the yum package manager. For the i386 kernel and an environment utilize this line of code:

In case of the x86_64 kernel, execute the following one from the shell:

Now, install the repository pac kage and import GPG key. The last one is used by yum for authenticating packages. Note that for this procedure root access is required:

The system is ready for further actions, so you can easily install the Redis server and the PhpRedis extension via yum. Please note that it is necessary to enable the Redis server to be run at boot, as well as start the Redis service and restart the Apache service:

As for the workstation configuration, it is briefly described below. Since Debian already includes Redis server, you do not have to add any new repository to the Ubuntu system. But you should take care of the PhpRedis package. Use the following code:

Now, it’s time to install the PhpRedis extension via PECL. Besides, you should:

  • inform PHP about your improvements;
  • enable the new PHP extension;
  • restart the Apache service.

Utilize the following commands to perform all these actions:

After the extension is installed, the system is informed, and the Apache server is restarted, test Redis server by pinging it:

Note that you should receive PONG to go any further.

To see if everything is fine with the Redis extension (PHP loads it), run the following code:

String redis is a result you should get.

While configuring Redis as a cache, don’t forget that each key has its expire set. Use  maxmemory to set a maximum memory limit:

In the aforementioned example, it is 2 megabytes; consequently, there is no need for the app to use a time to live for keys with the help of the EXPIRE command. With the following configuration, all the keys are evicted via an approximated LRU algorithm when the 2 megabyte limit is achieved. As a result, Redis acts as memcached.

For further information check these posts:

Magento Server Configuration: Composer

How To Set Up Server For Magento 2

Another important aspect of configuring server for Magento, especially for Magento 2, is the installation of Composer. To make it available on Debian, run the following command:

Now, you should verify the installation:

Don’t forget to set your exact version.

Magento Server Configuration: Git

How To Configure Server For Magento 2

To set up Git on your Magento server, you need a Droplet with Debian 8 and a sudo user. First of all, you should find out whether your package lists are updated or not. Execute the following command:

Now, install Git:

The next step requires setting your Git username and email:

and

To view your Git settings, go to the git config utility and run the following command there:

For further information, check this tutorial: How To Install Git.

Magento Server Configuration: IonCube

How To Set Up Server For Magento 2

Some Magento extensions require IonCube to be installed on your server. If you are going to use such modules, install the loader. IonCube requires the PHP programming language to be installed on the server. the following tutorial is based on Nano and Wget, since they are often installed on most servers. If not, you can easily install them.

For CentOS, use the following command:

In case of Ubuntu and Debian, use this one:

Now, you should download the IonCube Loader and unpack it. For 64Bit x86_64, utilize the following command:

For 32Bit i386, use this one:

Note that all files are unpacked into the “ioncube” folder.

Now, it is necessary to copy the loader for your current PHP version (in our case it is 5.6) to the PHP extension directory (in our case it is /usr/lib/php5/20141216):

Don’t forget to perlace our PHP version and the extension directory of our PHP version with your data.

To configure the IonCube loader on Debian, you have to change several php.ini files (Apache2, PHP CLI, CGI, and FPM). Depending on our needs, some files will not need ioncube loader support, so you can leave them untouchable. You can see, where are all these files situated:

Add the following line of code to files necessary for your Magento server configuration:

Don’t forget to set your PHP version and directory and restart both the apache webserver and php-fpm after saving the files:

For further information, follow this link: How to install Ioncube Loader.

Magento Server Configuration: XDebug and PHPUnit

How To Configure Server For Magento 2

XDebug & PHPUnit are must have tools for Magento 2 development, so install them on your server, if you are going to tinker your Magento website.

XDebug PECL Installation

You can install Xdebug on your Magento server with the aid of PEAR/PECL. Just run the following command:

Besides, you should add a new line to your php.ini file:

Please note that it is necessary to replace the path and filename from the code with your exact data. Use the full path only. For further information and other ways of Xdebug installation on the server optimized for Magento, check this tutorial: XDEBUG EXTENSION FOR PHP.

PHPUnit

The most simple way to install PHPUnit on your Magento server requires downloading a PHP Archive (PHAR). The required extensions are phar and openssl. Allow the execution of PHARs in the php.ini file, in case Suhosin is enabled:

The following command will install PHAR globally:

Alternatively, you can utilize the PHAR file directly:

For further information, check this tutorial: Installing PHPUnit

Magento Server Configuration: Solr

How To Set Up Server For Magento 2

You can also enhance your Magento search with Solr. The engine is supported by both Magento 2 and 1.X. To  install Solr on your Magento server, choose between either solr-tomcat or solr-jetty:

or

You can find more information here: Solr installation

Magento Server Configuration: Varnish

How To Configure Server For Magento 2

Although Varnish is available in Debian package repositories, its version might be old. Therefore, it is necessary to use packages from official sources. To install Varnish on your Magento server, run the following commands as as a root user:

For further information check this guides:

Magento Server Configuration: Special Magento 2 Requirements

Below, we shed light on server requirements of Magento 2. Although Grunt and RabbitMQ are not mandatory, but they essentially simplify your daily  routine with Magento 2.

Grunt

How To Set Up Server For Magento 2

To install Grunt on your Magento server, run the following command:

Replace “VERSION” with the version you need.

More information is available here:

RabbitMQ

How To Configure Server For Magento 2

Both Debian and Ubuntu includes rabbitmq-server out-of-the-box, but its version is often outdated. Therefore, we recommend you to download the latest available package from RabbiMQ’s website. For further information, check these posts:

Magento Server Configuration: Software Versions And Prerequisites

It is very important to check prerequisites before installing Magento on your server. Note that required software versions are often renewed, so you should be attentive to prerequisites before installing any software on your server, since it might be outdated. Check the official Dev Doc for further information: Prerequisites.

_______

That was our guide to Magento server configuration. We hope it will help you set up and configure server for your Magento 2 and 1.X projects. You are welcome to share your thoughts regarding Magento server configurations in the following comment field:

'