Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Magento 2 Cookbook

You're reading from   Magento 2 Cookbook Exploring Magento 2 in the form of recipes

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher
ISBN-13 9781785887062
Length 342 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Toc

Table of Contents (10) Chapters Close

Preface 1. Installing Magento 2 on Apache and NGINX 2. Magento 2 System Tools FREE CHAPTER 3. Enabling Performance in Magento 2 4. Creating Catalogs and Categories 5. Managing Your Store 6. Creating a Magento 2 Theme 7. Creating Magento 2 Extensions – the Basics 8. Creating Magento 2 Extensions – Advanced Index

Installing NGINX

Throughout the following recipes, we will install the latest NGINX 1.9.x version on a SaaS platform hosted by DigitalOcean. The current NGINX version supports HTTP/2. This recipe will show you how to do it.

Getting ready

For this recipe, you will need to create an account at DigitalOcean https://www.digitalocean.com/. No other prerequisites are required.

Tip

For this cookbook, we will use a commercial SaaS hosting provider to get a production-ready environment. You can use any other solution out there to build on your preferred stack.

How to do it...

For the purpose of this recipe, let's assume that we need to create an NGINX hosting environment. The following steps will guide you through this:

  1. Follow steps 1 until 6 in the previous recipe on how to install Apache.
  2. Then, we will update our server to the latest updates available:
    apt-get update && apt-get -y upgrade
    
  3. Next, we will install NGINX using the latest mainline version 1.9.x. Currently, Ubuntu doesn't include the latest NGINX 1.9.x mainline version. The latest change log can be viewed at http://nginx.org/en/CHANGES. Run the following command:
    echo "deb http://nginx.org/packages/mainline/ubuntu/ wily nginx" | sudo tee -a /etc/apt/sources.list.d/nginx.list
    echo "deb-src http://nginx.org/packages/mainline/ubuntu/ wily nginx" | sudo tee -a /etc/apt/sources.list.d/nginx.list
    
  4. Before we can install NGINX, we need to authorize the package by installing a signed key:
    wget http://nginx.org/keys/nginx_signing.key | apt-key add nginx_signing.key
    
  5. Now, we will update our Ubuntu system using the latest NGINX packages:
    apt-get update && apt-get -y install nginx
    
  6. Once every NGINX package is installed, we can check whether everything is in order by running the following command on the shell:
    nginx -v
    

    The output of this command is as follows:

    root@mage2cookbook:~# nginx -v
    nginx version: nginx/1.9.6
    

If you have followed steps 1 to 6, you will be able to see if the web server is running. Go to your favorite browser and search using your yourdomain.com.

Tip

In the DigitalOcean control panel, you can create multiple snapshots at all times during the recipes. This will help you in restoring an old version or just going back in time, such as switching from Apache to NGINX or back.

How it works…

Let's recap and find out what we did throughout this recipe. In steps 1 through 5, we used the same Droplet to install NGINX. All steps are alike, but instead of installing Apache, we use NGINX instead. The only big difference is that it is an official NGINX repository.

There's more…

The current market share of NGINX is around 15% worldwide compared to 50% of Apache on active sites. Over the last couple of years, NGINX has grown and is commonly used as a stable web server for Magento hosting:

http://news.netcraft.com/archives/2015/03/19/march-2015-web-server-survey.html

If you want to check whether NGINX is running fine, use one of the following commands:

service nginx status
netstat -anp | grep nginx
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime