I'm trying to setup a server for Magento 2.
I'm following through the official documentation, but it's patchy at best. For example, as of writing there is no direct method of installing PHP7.02 on Centos other than following their non officially recommended method of using the IUS repository.

Is there a recommended server setup for Magento 2 that we could follow along and easily spin up servers?

The answer I'm looking for would include

  • Which OS is better (CentOS, Ubuntu, Debian)
  • Which web server is better (Apache 2.2 or 2.4, nginx 1.8 or later)
  • Which Database is better (MySQL 5.6, MariaDB or Percona)
  • What PHP version (5.5, 5.6, 7.02, 7.06)
  • PHP libraries (would include the ones listed by Magento)
  • Additional PHP components and settings, like PHP OPcache and memory_limit
  • Mail server (Magento mentions MTA or an SMTP server)
  • Anything else like Redis, Varnish, Memcached etc

Ideally, once I figure out all of the above, I can then write a bash script to easily spin up Magento2 instances.

I am not looking for an out of the box one line command to install Magento2, rather I'm looking for a recommended stack starting with the OS and down.

  • 1
    Possible duplicate of Easy to Deploy 2 server setup on AWS
    – MagenX
    Jan 14, 2018 at 20:55
  • @MagenX the OP on the thread you referenced is looking for a one command install script, I'm looking for best practices all along the stack. The script you provide in your answer assumes that the user is on CentOs 7
    – Haim
    Jan 14, 2018 at 22:35
  • the answer that you are looking for ...
    – MagenX
    Jan 15, 2018 at 7:34
  • 1
    Every once in a while a question like this pops up here on Magento SE. Of course it is logical that one would question this, but unfortunately this question is not right for the SE Q&A format. Answers to this question would be highly subjective and very localized. So dozens of answers could and would be given and none of them would be 100% right and almost none of them 100% wrong. It would lead more to discussion than Q&A. I'd suggest to check the Magento forums: community.magento.com/t5/forums/searchpage/tab/…
    – 7ochem
    Jan 15, 2018 at 9:43

1 Answer 1


Which OS is better (Ubuntu)

Which web server is better (Apache 2)

Which Database is better (MySQL 5.6)

What PHP version (7.1)

Install Varnish.

  • 1
    According to Magento dev docs, PHP 7.1 is not supported
    – Haim
    Jan 12, 2018 at 5:32
  • I already using it and it's working for me.
    – user53816
    Jan 12, 2018 at 5:35
  • If you choose 7.0 than it's also ok.
    – user53816
    Jan 12, 2018 at 5:36
  • I'm trying to figure out the best way, why would you recommend PHP7.01 over PHP7.02
    – Haim
    Jan 12, 2018 at 5:38
  • 1
    @Haim Please check devdocs.magento.com/guides/v2.2/install-gde/…
    – user53816
    Jan 12, 2018 at 6:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.