A little bit about myself before I jump into the review. My name is Mathew Davies, I’m a PHP developer from a small village in England called Barton-Le-Clay and I’m also roller coaster enthusiast. I run a fairly big website dedicated to my hobby (nolimits-exchange) so I’m always on the lookout to improve performance while keeping the costs down. That’s how I came to understand Nginx with its low memory and CPU requirements, perfect for my small VPS.
I was kindly asked to review the book and I couldn’t miss out reviewing the first Nginx book. Special thanks go to PacktPub for giving me the opportunity to do so.
The book is about Nginx (aka Engine x) which is gaining a lot of popularity throughout the server world. This is down to its asynchronous architecture and low memory and CPU requirements; Perfect for squeezing more performance out of your current hardware. The book aims to convert over Apache users and anyone with an interest in optimizing their infrastructure.
I was confused about the first chapter Preparing your Work Environment. It explains such basics as: How to use a terminal emulator (Putty), the Linux directory layout and file permissions. The blurb gave me the impression that you should be able to administer a Linux server to a basic level, so to find this information was a bit odd. I don’t expect the first chapter to be useful to the target audience. Putting this into consideration, I would remove the first chapter and make it up by going into Nginx module development; A subject which could benefit.
I found one mistake in the first chapter. On page 44, the octal permissions are wrong, here is what is in the book:
and what the values should be:
The next chapter Downloading and Installing Nginx is basic and teaches the reader how to compile Nginx along with its dependencies. It would have been educating to show the reader how to install the packages with apt-get or aptitude. I suggest this because the first chapter assumes the reader has little to zero knowledge of Linux.
Chapters three till five are about the Nginx configuration directives and modules. A lot of the content here can be found online at websites like the Nginx Wiki, but it goes into more detail with real life examples. They serve as a great reference and will probably be the most used after the initial learning is over.
We then get into the realm of setting up a PHP-FPM/Python combo. Just a note about the PHP-FPM guide: FPM is now part of PHP from version 5.3.3 onwards, you no longer need to apply the FPM patch. It’s recommenced you avoid the patch as it’s no longer maintained. I did learn something new from this chapter: Setting up PHP as an upstream server in Nginx. Normally I’d just use fastcgi_pass directly to the server, but the upstream block makes it easier to scale out your application servers.
If you don’t want to move to Nginx right away, it might be a good idea to keep Apache as the backend and use Nginx as the front-end. This means you can free Apache of processing your static files (css and js) which gives it a bit more memory to play with; Your static content will get served faster too! Apache and Nginx Together goes into how you would set this up and describes common problems you might encounter (forwarding client IP addresses, SSL issues, etc …)
So, you’ve decided to move to Nginx after hearing how great it is, now you’re thinking “Where do I start?”. From Apache to Nginx (Chapter 8) will be able to help you there. Personal experience of being on the Nginx mailing list tells me this chapter is going to be helpful to those who are strugging to port over their rewrite rules and server configurations. Direct comparisons have been between both software configuration styles so it’s easy to see how Apache directives translate. Rewrite rules for popular web applications such as Wordpress have been included for convenience and even more can be found online at the Nginx Wiki.
The book was an enjoyable read and I took away some methods which will help scale my website in the future. I’d certainly recommend the book to anyone who doesn’t use Nginx (just to see what they’re missing out on) or a basic Nginx user who wants to further their knowledge on the subject. It covers most of what you’ll need and makes improvements where the Nginx Wiki is lacking.
One suggestion: Page 105 Upgrading Nginx Gracefully should include how to switch back to your old Nginx process if the new one failed to work. Here is how that would be done:
kill -HUP 123 - this will restart the workers under the old master process kill -QUIT 321 - shuts down the new master process workers kill -TERM 321 - shuts down the new master process
I also spotted a minor syntax error (missing “;”) and a bit of code that was copied and pasted, but not changed. That said, it’s a great book and despite its mistakes I recommend purchasing it.
A free chapter is available from PacktPub, check it out: Basic Nginx Configuration
I specialize in PHP development and work with the Kohana framework. I have several open source modules available and they can be found on my github page: thepixeldeveloper. I’m available for hire and can be contacted using the email address in the website footer.