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
NGINX Cookbook
NGINX Cookbook

NGINX Cookbook: Over 70 recipes for real-world configuration, deployment, and performance

Arrow left icon
Profile Icon Tim Butler
Arrow right icon
Can$34.98 Can$49.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.3 (4 Ratings)
eBook Aug 2017 278 pages 1st Edition
eBook
Can$34.98 Can$49.99
Paperback
Can$61.99
Subscription
Free Trial
Arrow left icon
Profile Icon Tim Butler
Arrow right icon
Can$34.98 Can$49.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.3 (4 Ratings)
eBook Aug 2017 278 pages 1st Edition
eBook
Can$34.98 Can$49.99
Paperback
Can$61.99
Subscription
Free Trial
eBook
Can$34.98 Can$49.99
Paperback
Can$61.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

NGINX Cookbook

Common PHP Scenarios

In this chapter, we will cover the following recipes:

  • Configuring NGINX for WordPress
  • WordPress multisite with NGINX
  • Running Drupal using NGINX
  • Using NGINX with MediaWiki
  • Using Magento with NGINX
  • Configuring NGINX for Joomla

Introduction

PHP is a thoroughly tested product to use with NGINX because it is the most popular web-based programming language. It powers sites, such as Facebook, Wikipedia, and every WordPress-based site, and its popularity hasn't faded as other languages have grown.

In this chapter, we'll go through examples of the more common PHP scenarios and how to implement them with NGINX. As WordPress is the most popular of the PHP systems, I've included some additional information to help with troubleshooting. Even if you're not using WordPress, some of this information may be helpful if you run into issues with other PHP frameworks.

Most of the recipes expect that you have a working understanding of PHP systems, so not all of the setup steps for the systems will be covered. This is to keep the book succinct and allow the focus to be on the NGINX components.

In order...

Configuring NGINX for WordPress

Covering nearly 30 percent of all websites, WordPress is certainly the Content Management System (CMS) of choice by many. Although it came from a blogging background, WordPress is a very powerful CMS for all content types and powers some of the world's busiest websites.

By combining it with NGINX, you can deploy a highly scalable web platform.

You can view the official WordPress documentation on NGINX at https://codex.wordpress.org/Nginx.

We'll also cover some of the more complex WordPress scenarios, including multisite configurations with subdomains and directories.

Let's get started.

Getting ready

To compile PHP code and run it via NGINX, the preferred method is via PHP-FPM...

WordPress multisite with NGINX

WordPress multisites (also referred to as network sites) allow you to run multiple websites from the one codebase. This can reduce the management burden of having separate WordPress installations when you have similar sites. For example, if you have a sporting site with separate news and staff for different regions, you can use a multisite installation to accomplish this.

How to do it...

To convert a WordPress site into a multisite, you need to add the configuration variable into your config file wp-config.php:

define( 'WP_ALLOW_MULTISITE', true ); 

Under the Tools menu, you'll now see an extra menu called Network Setup. This will present you with two main options, Sub-domains...

Running Drupal using NGINX

With version 8 recently released and a community of over 1 million supporters, Drupal remains a popular choice when it comes to a highly flexible and functional CMS platform. Version 8 has over 200 new features compared to version 7, aimed at improving both the usability and manageability of the system. This cookbook will be using version 8.0.5.

Getting ready

How to do it...

...

Using NGINX with MediaWiki

MediaWiki, most recognized by its use with Wikipedia, is the most popular open source wiki platform available. With features heavily focused on the ease of editing and sharing content, MediaWiki makes a great system to store information you want to continually edit:

Getting ready

How to do it...

The basic...

Using Magento with NGINX

With nearly 30 percent market share, Magento is the most popular e-commerce platform in the world. Due to a number of features and complexity, it's also a very resource-intensive system to use compared to a lightweight alternative. This means that NGINX is an ideal pairing to ensure you have the highest performance possible.

The latest major version of Magento is 2.0, which was nearly a complete rewrite compared to the previous versions. There's still quite a bit of complexity involved too, so make sure that you're ready to take on Magento if you've chosen it for your e-commerce platform:

Getting ready

This guide assumes you're familiar with the installation of Magento 2.0...

Configuring NGINX for Joomla

With the recent release of version 3.5, Joomla is still one of the most popular CMS platforms in the world. This latest release features full PHP 7 support, drag-and-drop images, and more:

Getting ready

How to do it...

To use Joomla with NGINX, we need a simple NGINX configuration file. This is a very basic PHP-FPM configuration...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Be the first to immerse yourself in the NGINX 1.9x web server and explore the plethora of advanced features.
  • Master the skills of load balancing TCP-based applications and implementing HTTP/2.
  • A recipe-based approach book that provides you with up-to-date information on NGINX, allowing you to implement specific use cases immediately.

Description

NGINX Cookbook covers the basics of configuring NGINX as a web server for use with common web frameworks such as WordPress and Ruby on Rails, through to utilization as a reverse proxy. Designed as a go-to reference guide, this book will give you practical answers based on real-world deployments to get you up and running quickly. Recipes have also been provided for multiple SSL configurations, different logging scenarios, practical rewrites, and multiple load balancing scenarios. Advanced topics include covering bandwidth management, Docker container usage, performance tuning, OpenResty, and the NGINX Plus commercial features. By the time you've read this book, you will be able to adapt and use a wide variety of NGINX implementations to solve any problems you have.

Who is this book for?

This book is aimed at smaller-to-medium developers, who are just getting started with NGINX. It assumes they already understand the basics of how a web server works and how basic networking works.

What you will learn

  • • Practical, real-world examples and recipes on how to use NGINX
  • • Common CMS deployments such as WordPress, Joomla and more
  • • NGINX configurations for frameworks such as Ruby on Rails, Django and more
  • • Detailed SSL recipes, including HTTP/2
  • • Real world rewrite examples
  • • Basic web and TCP load balancing configuration
  • • Bandwidth management and connection limiting
  • • Detailed NGINX deployment scenarios with Docker
  • • Performance tuning and monitoring of your NGINX deployments
  • • OpenResty deployment guides
  • • Advanced deployments with NGINX Plus features

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 31, 2017
Length: 278 pages
Edition : 1st
Language : English
ISBN-13 : 9781786469779
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Aug 31, 2017
Length: 278 pages
Edition : 1st
Language : English
ISBN-13 : 9781786469779
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Can$ 193.97
Nginx HTTP Server
Can$61.99
Mastering NGINX
Can$69.99
NGINX Cookbook
Can$61.99
Total Can$ 193.97 Stars icon

Table of Contents

13 Chapters
Let's Get Started Chevron down icon Chevron up icon
Common PHP Scenarios Chevron down icon Chevron up icon
Common Frameworks Chevron down icon Chevron up icon
All About SSLs Chevron down icon Chevron up icon
Logging Chevron down icon Chevron up icon
Rewrites Chevron down icon Chevron up icon
Reverse Proxy Chevron down icon Chevron up icon
Load Balancing Chevron down icon Chevron up icon
Advanced Features Chevron down icon Chevron up icon
Docker Containers Chevron down icon Chevron up icon
Performance Tuning Chevron down icon Chevron up icon
OpenResty Chevron down icon Chevron up icon
NGINX Plus – The Commercial Offering Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.3
(4 Ratings)
5 star 25%
4 star 25%
3 star 0%
2 star 50%
1 star 0%
Packt Nov 25, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Really liked this book AR.
Subscriber review Packt
Amazon Customer Nov 24, 2019
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This is kind of a turd. The nginx parts are nice but it leaves you hanging on the examples. It shows you how to configure nginx for wordpress but doesn't even show the basics of actually getting wordpress up and running on nginx. This causes the reader to have to look elsewhere for that information and thus divide their attention. A basic here's how to configure php and msql would have taken a couple of pages at the most. I'd return it to Amazon if I still had time.
Amazon Verified review Amazon
Tom L Jan 19, 2018
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I maintain about a dozen small websites that were migrated last year from on-site to cloud based services. As a part of the migration I converted all of the configurations from Apache to Nginx. This book was on my Wishlist and I received it as a gift. I read the one review and had hoped that this book would have covered the various Nginx features in depth. I may have missed some feature in my Apache to Nginx conversion that would prove useful. I did not receive any benefit from reading this book. It was just a 'cookbook' of Nginx configurations for various content based server software packages with 'Linux centric' commands for installation and startup. All of my sites are *BSD (FreeBSD, OpenBSD and NetBSD) based and the 'apt-get' type of commands for package retrieval and configuration are very foreign to me. I won't give this book the lowest score. I'll put it on my bookshelf and may have a use for it someday.
Amazon Verified review Amazon
Texan Oct 04, 2017
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This is a very useful book for someone that needs to get a jump start into NGINX. A lot of the material can be found on the NGINX site and on the web but this book does a good job of putting a lot of the more interesting stuff in one place. I particularly like the organization of almost every "recipe" into four sections: Getting ready, How to do it..., How it works, and There's more. It allows you to very quickly focus in on what you need without having to read the entire book. It is very much organized like a food cookbook. It's a bit pricey and I think if he knocked ten bucks off the price he'd get a lot more sales. I'd probably have given this five stars as it definitely saved me the price of the book in the first day of use in terms of the time I'd otherwise spend in digging out the info on the web. However, I bought the Kindle version and sometimes the rendering is a bit problematic with e-books. This was the case here. In my Kindle for Mac reader the "tip" bubbles overlaid the tip making it a bit harder to read and some of the fonts were a bit odd looking compared to what you typically find in print books. But the material seems solid. As a PAKT book you can get all of the configuration/source files from their site and that is helpful. I noted that the took text actually seems to be more up to date than those files as there was a small difference in one of the recipes but the book text agreed with what I found on the NGINX official site for proxy setup. It was minor but I noticed it so I mention it here. I'm happy with the purchase because it saved me a lot of time getting started with NGINX (I'm on an accelerated project) and it covers the waterfront of NGINX pretty well, including some nice comments about the "why" of it all that you don't always find in reference works.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.