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.
For this recipe, you will need to create an account at DigitalOcean https://www.digitalocean.com/. No other prerequisites are required.
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:
apt-get update && apt-get -y upgrade
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
wget http://nginx.org/keys/nginx_signing.key | apt-key add nginx_signing.key
apt-get update && apt-get -y install nginx
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
.
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.
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
18.119.19.174