{"id":22249,"date":"2017-05-18T07:24:48","date_gmt":"2017-05-18T12:24:48","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=22249"},"modified":"2022-06-03T03:42:10","modified_gmt":"2022-06-03T08:42:10","slug":"how-to-install-magento-2-with-apache-varnish-and-memcache","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/","title":{"rendered":"How to Install Magento 2 with Apache, Varnish and Memcache"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p><img decoding=\"async\" class=\"img-responsive alignnone wp-image-22251 size-full\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg\" alt=\"magento 2 with memcache\" width=\"1200\" height=\"600\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg 1200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-150x75.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-300x150.jpg 300w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-768x384.jpg 768w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-1024x512.jpg 1024w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-860x430.jpg 860w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-680x340.jpg 680w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-500x250.jpg 500w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-400x200.jpg 400w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-200x100.jpg 200w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem-50x25.jpg 50w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>In this article, we will show you how to install Magento 2 on an <a href=\"https:\/\/www.rosehosting.com\/ubuntu-hosting.html\">Ubuntu 16.04 VPS<\/a> with MariaDB, Varnish as a full page cache, Apache and Memcache for session storage. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 16.04 VPS.<!--more--><\/p>\n<p>Before we begin, you may want a different setup for your Magento. You can follow <a href=\"https:\/\/www.rosehosting.com\/blog\/magento-2-with-redis-varnish-and-nginx-as-ssl-termination\/\">this tutorial<\/a> to install Magento 2 on an Ubuntu 16.04 VPS with MariaDB, PHP-FPM 7.0, Varnish as a full page cache, Nginx as SSL termination and Redis for session storage and page caching.<\/p>\n<p>If you have any different requirements, just <a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting.html\">get a Linux VPS from us<\/a> and we&#8217;ll set everything up for you, free of charge.<\/p>\n<p><strong>INSTRUCTIONS:<\/strong><\/p>\n<p>First of all login to your Ubuntu 16.04 VPS <a href=\"https:\/\/www.rosehosting.com\/blog\/connect-to-your-linux-vps-via-ssh\/\">via SSH<\/a> as user root<\/p>\n<pre>ssh root@IP_address<\/pre>\n<p>At the very beginning, it is best to start a <a href=\"https:\/\/www.rosehosting.com\/blog\/basic-screen-command-usage-and-examples\/\">screen session<\/a> by executing the following command<\/p>\n<pre>screen -U -S magento<\/pre>\n<p><a href=\"https:\/\/www.rosehosting.com\/blog\/update-the-software-on-linux\/\">Update the system<\/a> and install necessary packages:<\/p>\n<pre>apt-get update &amp;&amp; apt-get -y upgrade\r\napt-get -y install curl nano git<\/pre>\n<p>Make sure to always keep your server up to date. You can even <a href=\"https:\/\/www.rosehosting.com\/blog\/how-to-enable-automatic-updates-on-a-linux-vps\/\">enable automatic updates<\/a>.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f19ab8d8fea\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69f19ab8d8fea\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Install-and-configure-MariaDB-101\" >Install and configure MariaDB 10.1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Install-Apache2-web-server\" >Install Apache2 web server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Install-PHP-and-required-PHP-modules\" >Install PHP and required PHP modules<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Install-Composer\" >Install Composer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Install-Magento-2-from-Github\" >Install Magento 2 from Github<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Configure-Apache\" >Configure Apache<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Install-and-configure-Varnish\" >Install and configure Varnish<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Install-and-configure-Memcache-caching\" >Install and configure Memcache caching<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#Further-Optimizations\" >Further Optimizations<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Install-and-configure-MariaDB-101\"><\/span>Install and configure MariaDB 10.1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To add the MariaDB repository to your sources list and install the latest MariaDB server, run the following commands:<\/p>\n<pre>apt-get install software-properties-common\r\napt-key adv --recv-keys --keyserver hkp:\/\/keyserver.ubuntu.com:80 0xF1656F24C74CD1D8\r\nadd-apt-repository 'deb [arch=amd64,i386,ppc64el] https:\/\/mirrors.evowise.com\/mariadb\/repo\/10.1\/ubuntu xenial main'<\/pre>\n<p>Once the key is imported and the repository added you can install MariaDB with:<\/p>\n<pre>apt-get update &amp;&amp; apt-get -y upgrade\r\napt-get install mariadb-server<\/pre>\n<p>Next, we need to create a database for our Magento installation.<\/p>\n<pre>mysql -uroot -p<\/pre>\n<pre>MariaDB [(none)]&gt; CREATE DATABASE magento;\r\nMariaDB [(none)]&gt; GRANT ALL PRIVILEGES ON magento.* TO 'magento'@'localhost' IDENTIFIED BY 'my_strong_password';\r\nMariaDB [(none)]&gt; FLUSH PRIVILEGES;\r\nMariaDB [(none)]&gt; \\q<\/pre>\n<p>Do not forget to replace \u2018my_strong_password\u2019 with a strong password.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Install-Apache2-web-server\"><\/span>Install Apache2 web server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre>[user]$ sudo apt-get install apache2<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Install-PHP-and-required-PHP-modules\"><\/span>Install PHP and required PHP modules<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To install the latest stable version of PHP version 7 and all necessary modules, run:<\/p>\n<pre>[user]$ apt-get install php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-xsl php-imagick php7.0-gd php7.0-cli php-pear php7.0-intl<\/pre>\n<p>Change few default PHP settings:<\/p>\n<pre>[user]$ sed -i \"s\/memory_limit = .*\/memory_limit = 256M\/\" \/etc\/php\/7.0\/cli\/php.ini\r\n[user]$ sed -i \"s\/upload_max_filesize = .*\/upload_max_filesize = 128M\/\" \/etc\/php\/7.0\/cli\/php.ini\r\n[user]$ sed -i \"s\/zlib.output_compression = .*\/zlib.output_compression = on\/\" \/etc\/php\/7.0\/cli\/php.ini\r\n[user]$ sed -i \"s\/max_execution_time = .*\/max_execution_time = 18000\/\" \/etc\/php\/7.0\/cli\/php.ini<\/pre>\n<p>Enable the Apache2 rewrite module if it is not already done:<\/p>\n<pre>[user]$ a2enmod rewrite<\/pre>\n<p>In order to activate the new configuration, restart the Apache web server using the following command:<\/p>\n<pre>[user]$ service apache2 restart<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Install-Composer\"><\/span>Install Composer<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies you need for your project.<\/p>\n<pre>[user]$ curl -sS https:\/\/getcomposer.org\/installer | php\r\nmv composer.phar \/usr\/local\/bin\/composer<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Install-Magento-2-from-Github\"><\/span>Install Magento 2 from Github<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Clone the Magento repository to the <code>~\/myMagentoSite.com<\/code> directory using the following command:<\/p>\n<pre>[user]$ git clone https:\/\/github.com\/magento\/magento2.git \/var\/www\/myMagentoSite.com<\/pre>\n<p>Get the latest Magento 2 stable release:<\/p>\n<pre>[user]$ cd \/var\/www\/myMagentoSite.com<\/pre>\n<pre>[user]$ git checkout $(git describe --tags $(git rev-list --tags --max-count=1))<\/pre>\n<p>Run composer to install all Magento dependencies:<\/p>\n<pre>[user]$ composer install<\/pre>\n<p>To continue with the installation you can either use the installation wizard or the command line, in this guide we will use the latter.<\/p>\n<pre>[user]$ bin\/magento setup:install \\\r\n--base-url=http:\/\/myMagentoSite.com\/ \\\r\n--db-host=localhost \\\r\n--db-name=magento \\\r\n--db-user=magento \\\r\n--db-password=my_strong_password \\\r\n--admin-firstname=First  \\\r\n--admin-lastname=Last \\\r\n--admin-email=user@myMagentoSite.com \\\r\n--admin-user=admin \\\r\n--admin-password=my_strong_password123 \\\r\n--language=en_US \\\r\n--currency=USD \\\r\n--timezone=America\/Chicago \\\r\n--use-rewrites=1<\/pre>\n<p>If the installation is successful you will see something like below:<\/p>\n<pre>[SUCCESS]: Magento installation complete.\r\n[SUCCESS]: Magento Admin URI: \/admin_t0x0nr<\/pre>\n<p>Run the <code>crontab<\/code> command to create a cronjob<\/p>\n<pre>crontab -u www-data -e<\/pre>\n<p>and add the following line:<\/p>\n<pre>* * * * * \/usr\/bin\/php \/var\/www\/myMagentoSite.com\/bin\/magento cron:run | grep -v \"Ran jobs by schedule\" &gt;&gt; \/var\/www\/myMagentoSite.com\/var\/log\/magento.cron.log<\/pre>\n<p>Finally, set the correct permissions:<\/p>\n<pre>[user]$ chown -R www-data: \/var\/www\/myMagentoSite.com<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Configure-Apache\"><\/span>Configure Apache<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Create a new virtual host directive in Apache. For example, create a new Apache configuration file named \u2018magento.conf\u2019 on your virtual server:<\/p>\n<pre>[user]$ touch \/etc\/apache2\/sites-available\/magento.conf\r\n[user]$ ln -s \/etc\/apache2\/sites-available\/magento.conf \/etc\/apache2\/sites-enabled\/magento.conf\r\n[user]$ nano \/etc\/apache2\/sites-available\/magento.conf<\/pre>\n<p>Then, add the following lines:<\/p>\n<pre>&lt;VirtualHost *:80&gt;\r\nServerAdmin admin@yourdomain.com\r\nDocumentRoot \/var\/www\/myMagentoSite.com\/\r\nServerName myMagentoSite.com\r\nServerAlias www.myMagentoSite.com\r\n&lt;Directory \/var\/www\/myMagentoSite.com\/&gt;\r\nOptions FollowSymLinks\r\nAllowOverride All\r\nOrder allow,deny\r\nallow from all\r\n&lt;\/Directory&gt;\r\nErrorLog \/var\/log\/apache2\/myMagentoSite.com-error_log\r\nCustomLog \/var\/log\/apache2\/myMagentoSite.com-access_log common\r\n&lt;\/VirtualHost&gt;\r\n<\/pre>\n<p>Restart the Apache web server for the changes to take effect:<\/p>\n<pre>[user]$ sudo service apache2 restart<\/pre>\n<p>You should be now able to login to your Magento back-end by going to <code>http:\/\/myMagentoSite.com\/admin_t0x0nr<\/code> using the information you set when running the <code>bin\/magento setup:install<\/code>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Install-and-configure-Varnish\"><\/span>Install and configure Varnish<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Installing Varnish is as simple as running the following command:<\/p>\n<pre>[user]$ apt-get install varnish<\/pre>\n<p>From you Magento Admin dashboard click on the STORES link (left sidebar) -&gt; Configuration -&gt; ADVANCED -&gt; System -&gt; Full Page Cache<\/p>\n<p>Unselected Use system value and from the Caching Application list, select Varnish Cache (Recommended), save the configuration, click on the Varnish Configuration link and click on the Export VCL for Varnish 4 button. The <code>varnish.vcl<\/code> file which we will use will be exported in the <code>\/var\/www\/myMagentoSite.com\/var\/<\/code> directory.<\/p>\n<p>Flush the Magento cache with:<\/p>\n<pre>[user]$ php bin\/magento cache:flush<\/pre>\n<p>Delete the <code>\/etc\/varnish\/default.vcl<\/code> and symlink it to the exported varnish configuration.<\/p>\n<pre>[user]$ rm -f \/etc\/varnish\/default.vcl\r\n[user]$ ln -sf \/var\/www\/myMagentoSite.com\/var\/varnish.vcl \/etc\/varnish\/default.vcl<\/pre>\n<p>To change varnish port from 6081 to 80, we need to edit the systemd service configuration.<\/p>\n<p>Create a new <code>customexec.conf<\/code> file<\/p>\n<pre>[user]$ mkdir -p \/etc\/systemd\/system\/varnish.service.d\r\n[user]$ nano \/etc\/systemd\/system\/varnish.service.d\/customexec.conf<\/pre>\n<p>paste the following:<\/p>\n<pre>[Service]\r\nExecStart=\r\nExecStart=\/usr\/sbin\/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f \/etc\/varnish\/default.vcl -S \/etc\/varnish\/secret -s malloc,256m<\/pre>\n<p>and reload systemd units<\/p>\n<pre>[user]$systemctl daemon-reload<\/pre>\n<p>Now we need to change Apache listening port from 80 to 8080. To do that, open the Apache ports configuration file and change it as follows:<\/p>\n<pre>[user]$ nano \/etc\/apache2\/ports.conf\r\n\r\nListen 80 -&gt; Listen 8080<\/pre>\n<pre>[user]$ nano \/etc\/apache\/sites-available\/magento.conf\r\n\r\n&lt;VirtualHost *:80&gt; -&gt; &lt;VirtualHost *:8080&gt;<\/pre>\n<p>If everything is setup correctly now you should be able to login to your Magento back-end by going to <code>https:\/\/myMagentoSite.com\/admin_t0x0nr<\/code>.<\/p>\n<p>[ecko_alert color=&#8221;blue&#8221;]Stuck somewhere? <a href=\"https:\/\/www.rosehosting.com\/managed-vps-hosting.html\">Get a VPS<\/a> from us and we&#8217;ll do all of this for you, free of charge![\/ecko_alert]<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Install-and-configure-Memcache-caching\"><\/span>Install and configure Memcache caching<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Memcache is a key-value in memory data store and we will use it to replace the default Magento 2 Zend_Cache_Backend_File backend cache. Install Memcache by running the following command:<\/p>\n<pre>[user]$ apt-get install php-memcache memcached<\/pre>\n<p>Configure memcached to listen on localhost (127.0.0.1) and disable UDP:<\/p>\n<pre>vi \/etc\/memcached.conf<\/pre>\n<pre>-l 127.0.0.1\r\n-U 0<\/pre>\n<p>To configure your Magento installation to use Memcache for session storage open the <code>app\/etc\/env.php<\/code> file and change\/add the following:<\/p>\n<pre>[user]$ nano \/var\/www\/myMagentoSite.com\/app\/etc\/env.php<\/pre>\n<p>change:<\/p>\n<pre>'session' =&gt;\r\n    array (\r\n    'save' =&gt; 'files',\r\n),<\/pre>\n<p>with:<\/p>\n<pre>'session' =&gt;\r\n   array (\r\n      'save' =&gt; 'memcache',\r\n      'save_path' =&gt; 'tcp:\/\/127.0.0.1:11211'\r\n),<\/pre>\n<p>Finally flush the cache again:<\/p>\n<pre>[user]$ php bin\/magento cache:flush<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Further-Optimizations\"><\/span>Further Optimizations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To further optimize your Magento installation from you Magento admin dashboard:<\/p>\n<p>1. Go to STORES -&gt; Configuration -&gt; CATALOG -&gt; Catalog -&gt; Use Flat Catalog Category, select Yes and click Save Config.<br \/>\n2. Go to STORES -&gt; Configuration -&gt; ADVANCED -&gt; Developer -&gt; JavaScript Settings and set both Merge JavaScript Files and Minify JavaScript Files to Yes and click Save Config..<br \/>\n3. Go to STORES -&gt; Configuration -&gt; ADVANCED -&gt; Developer -&gt; CSS Settings and set both Merge CSS Files and Minify CSS Files to Yes and click Save Config.<br \/>\n4. Consider using a CDN \u2013 Content Delivery Network<\/p>\n<p>Do not forget to flush the cache again:<\/p>\n<pre>[user]$ php bin\/magento cache:flush<\/pre>\n<p>You can also follow our guide on how to <a href=\"https:\/\/www.rosehosting.com\/blog\/how-to-speed-up-magento\/\">speed up Magento<\/a>.<\/p>\n<p>That\u2019s it. You have successfully installed Magento 2 with Memcache as a session storage and page caching, Varnish as a full page caching and Apache on your Ubuntu 16.04 VPS. For more information about how to manage your Magento installation, please refer to the official <a title=\"Magento\" href=\"http:\/\/devdocs.magento.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Magento <\/a> documentation.<\/p>\n<hr \/>\n<p>Of course, you don\u2019t have to do any of this if you use one of our <a title=\"linux vps hosting\" href=\"https:\/\/www.rosehosting.com\/magento-hosting.html\" target=\"_blank\" rel=\"noopener noreferrer\">Magento VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24&#215;7 and will take care of your request immediately.<\/p>\n<p><span style=\"color: #ff0000;\"><strong>PS<\/strong><\/span>. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will show you how to install Magento 2 on an Ubuntu 16.04 VPS with MariaDB, Varnish &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Install Magento 2 with Apache, Varnish and Memcache\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#more-22249\" aria-label=\"Read more about How to Install Magento 2 with Apache, Varnish and Memcache\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":22251,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1709,1711,1707],"tags":[146,375,216,1559,533],"class_list":["post-22249","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-caching","category-e-commerce","category-web-servers","tag-cache","tag-ecommerce","tag-magento","tag-memcache","tag-varnish","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting<\/title>\n<meta name=\"description\" content=\"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install Magento 2 with Apache, Varnish and Memcache\" \/>\n<meta property=\"og:description\" content=\"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-18T12:24:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-03T08:42:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"How to Install Magento 2 with Apache, Varnish and Memcache\",\"datePublished\":\"2017-05-18T12:24:48+00:00\",\"dateModified\":\"2022-06-03T08:42:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/\"},\"wordCount\":985,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/magento2mem.jpg\",\"keywords\":[\"cache\",\"eCommerce\",\"magento\",\"memcache\",\"varnish\"],\"articleSection\":[\"Caching\",\"E-Commerce\",\"Web Servers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/\",\"name\":\"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/magento2mem.jpg\",\"datePublished\":\"2017-05-18T12:24:48+00:00\",\"dateModified\":\"2022-06-03T08:42:10+00:00\",\"description\":\"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/magento2mem.jpg\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/magento2mem.jpg\",\"width\":1200,\"height\":600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/how-to-install-magento-2-with-apache-varnish-and-memcache\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install Magento 2 with Apache, Varnish and Memcache\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting","description":"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/","og_locale":"en_US","og_type":"article","og_title":"How to Install Magento 2 with Apache, Varnish and Memcache","og_description":"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting","og_url":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2017-05-18T12:24:48+00:00","article_modified_time":"2022-06-03T08:42:10+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg","type":"image\/jpeg"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"How to Install Magento 2 with Apache, Varnish and Memcache","datePublished":"2017-05-18T12:24:48+00:00","dateModified":"2022-06-03T08:42:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/"},"wordCount":985,"commentCount":2,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg","keywords":["cache","eCommerce","magento","memcache","varnish"],"articleSection":["Caching","E-Commerce","Web Servers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/","url":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/","name":"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg","datePublished":"2017-05-18T12:24:48+00:00","dateModified":"2022-06-03T08:42:10+00:00","description":"How to Install Magento 2 with Apache, Varnish and Memcache | RoseHosting","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2017\/05\/magento2mem.jpg","width":1200,"height":600},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/how-to-install-magento-2-with-apache-varnish-and-memcache\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Install Magento 2 with Apache, Varnish and Memcache"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/22249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=22249"}],"version-history":[{"count":1,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/22249\/revisions"}],"predecessor-version":[{"id":41878,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/22249\/revisions\/41878"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/22251"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=22249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=22249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=22249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}