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!
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
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.
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.
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:
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
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:
thread_concurrency=[number of CPUs]*3
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
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:
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 repolistcommand 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:
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:
yum install redis php-pecl-redis
chkconfig redis on
service redis start
service httpd restart
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:
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.
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:
yum install nano wget
In case of Ubuntu and Debian, use this one:
apt-get install nano wget
Now, you should download the IonCube Loader and unpack it. For 64Bit x86_64, utilize the following command:
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:
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:
# pecl install xdebug
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.
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:
$sudo mv phpunit.phar/usr/local/bin/phpunit
PHPUnitx.y.zby Sebastian Bergmann andcontributors.
Alternatively, you can utilize the PHAR file directly:
PHPUnitx.y.zby Sebastian Bergmann andcontributors.
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:
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: