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! 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
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
NGINX Cookbook
NGINX Cookbook

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

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781786466174
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.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
€189.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 €5 each
Feature tick icon Exclusive print discounts
€264.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 €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 115.97
NGINX Cookbook
€36.99
Mastering NGINX
€41.99
Nginx HTTP Server
€36.99
Total 115.97 Stars icon
Banner background image

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
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
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
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
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.