Nginx HTTP server, 2nd edition

319 190 0
Nginx HTTP server, 2nd edition

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info Nginx HTTP Server Second Edition Make the most of your infrastructure and serve pages faster than ever with Nginx Clément Nedelcu BIRMINGHAM - MUMBAI www.it-ebooks.info Nginx HTTP Server Second Edition Copyright © 2013 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: July 2010 Second edition: July 2013 Production Reference: 1120713 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78216-232-2 www.packtpub.com Cover Image by Suresh Mogre (suresh.mogre.99@gmail.com) [ FM-2 ] www.it-ebooks.info Credits Author Project Coordinator Clément Nedelcu Rahul Dixit Reviewers Proofreader Michael Shadle Joel T Johnson Alex Kapranoff Indexer Rekha Nair Acquisition Editor Usha Iyer Graphics Valentina D'Silva Lead Technical Editor Azharuddin Sheikh Disha Haria Technical Editors Production Coordinator Vrinda Nitesh Bhosale Prachali Bhiwandkar Athira Laji Cover Work Dominic Pereira Prachali Bhiwandkar [ FM-3 ] www.it-ebooks.info About the Author Clément Nedelcu was born in France and studied in UK, French, and Chinese universities After teaching computer science and programming in several eastern Chinese universities, he worked as a Technology Consultant in France, specializing in web and Microsoft NET programming as well as Linux server administration Since 2005, he has also been administering a major network of websites in his spare time This eventually led him to discover Nginx: it made such a difference that he started his own blog about it One thing leading to another… I would like to express my gratitude to my wife Julie, my son Leo who was born during the writing of this book and never ceased to cheer me up; my family and my friends who have all been very supportive all along the writing stage This book is dedicated to Martin Fjordvald for originally directing me to Nginx when my servers were about to kick the bucket Special thanks to Cliff Wells, Maxim Dounin, and all the folks on the #nginx IRC channel on Freenode [ FM-4 ] www.it-ebooks.info About the Reviewers Michael Shadle is a self-proclaimed surgeon, when it comes to procedural PHP He has been using PHP for over ten years along with MySQL and various Linux and BSD distributions He has switched between many different web servers over the years and considers Nginx to be the best solution yet During the day he works as a senior Web Developer at Intel Corporation on a handful of public-facing websites He enjoys using his breadth of knowledge to come up with "out of the box" solutions to solve the variety of issues that come up During the off-hours, he has a thriving personal consulting, web development practice, and has many more personal project ideas than he can tackle at once He is a minimalist by heart, and believes that when architecting solutions, starting small and simple allows for a more agile approach in the long run Michael also coined the phrase, "A simple stack is a happy stack." Alex Kapranoff was born in a family of an electronics engineer and a programmer for old Soviet "Big Iron" computers He started to write programs at the age of 12 and has never worked outside of the IT industry since then After getting his Software Engineering degree with honors he had a short stint in the world of enterprise databases and Windows Then he settled on open-source Unix-like environments for good, first FreeBSD and then Linux, working as a developer for many Russian companies from ISPs to search engines Most of his experience has been with e-mail/ messaging systems and web security Right now he is trying his hand at a product and project management position in Yandex, one of the biggest search engines in the world He took his first look at Nginx working in Rambler side-by-side with Nginx's author Igor Sysoev before the initial public release of the product Since then, Nginx has been an essential tool in his kit He won't launch a website, no matter how complex it is, without using Nginx nowadays He strongly believes in the Free Software Movement, loves Perl, plain C, LISP, cooking, and fishing, and lives with a beautiful girlfriend and an old cat in Moscow, Russia [ FM-5 ] www.it-ebooks.info www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub com and as a print book customer, you are entitled to a discount on the eBook copy Get in touch with us at service@packtpub.com for more details At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library Here, you can access, read and search across Packt's entire library of books.€ Why Subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at€www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books Simply use your login credentials for immediate access [ FM-6 ] www.it-ebooks.info Table of Contents Preface 1 Chapter 1: Downloading and Installing Nginx Setting up the prerequisites GCC – GNU Compiler Collection The PCRE library The zlib library 10 OpenSSL 11 Downloading Nginx 11 Websites and resources 11 Version branches 13 Features 14 Downloading and extracting 15 Configure options 15 The easy way 16 Path options 16 Prerequisites options 18 Module options 20 Modules enabled by default Modules disabled by default 20 21 Miscellaneous options Configuration examples 22 24 Build configuration issues 26 Compiling and installing 27 About the prefix switch Regular HTTP and HTTPS servers All modules enabled Mail server proxy Make sure you installed the prerequisites Directories exist and are writable www.it-ebooks.info 24 25 25 26 26 27 Table of Contents Controlling the Nginx service Daemons and services User and group Nginx command-line switches Starting and stopping the daemon Testing the configuration Other switches Adding Nginx as a system service System V scripts What is an init script? Init script for Debian-based distributions Init script for Red Hat-based distributions Installing the script Debian-based distributions Red Hat-based distributions 28 28 28 29 29 30 31 31 32 33 33 34 34 35 35 Summary 36 Chapter 2: Basic Nginx Configuration Configuration file syntax Configuration Directives Organization and inclusions Directive blocks Advanced language rules 37 37 38 39 41 42 Directives accept specific syntaxes 42 43 Diminutives in directive values Variables 44 String values 44 Base module directives What are base modules? Nginx process architecture Core module directives Events module Configuration module A configuration for your profile Understanding the default configuration Necessary adjustments Adapting to your hardware Testing your server Creating a test server Performance tests 44 45 45 46 51 54 54 54 55 56 57 58 59 Httperf 59 Autobench 61 OpenWebLoad 62 [ ii ] www.it-ebooks.info Table of Contents Upgrading Nginx gracefully Summary 64 64 Chapter 3: HTTP Configuration 65 HTTP Core module Structure blocks Module directives Socket and host configuration 65 66 67 68 listen 68 server_name 68 server_name_in_redirect 69 server_names_hash_max_size 70 server_names_hash_bucket_size 70 port_in_redirect 70 tcp_nodelay 70 tcp_nopush 71 sendfile 71 sendfile_max_chunk 71 send_lowat 72 reset_timedout_connection 72 Paths and documents 72 Client requests 75 root 72 alias 73 error_page 73 if_modified_since 74 index 74 recursive_error_pages 75 try_files 75 keepalive_requests 76 keepalive_timeout 76 keepalive_disable 76 send_timeout 76 client_body_in_file_only 77 client_body_in_single_buffer 77 client_body_buffer_size 77 client_body_temp_path 78 client_body_timeout 78 client_header_buffer_size 78 client_header_timeout 79 client_max_body_size 79 large_client_header_buffers 79 lingering_time 80 lingering_timeout 80 lingering_close 80 ignore_invalid_headers 80 chunked_transfer_encoding 81 max_ranges 81 [ iii ] www.it-ebooks.info .. .Nginx HTTP Server Second Edition Make the most of your infrastructure and serve pages faster than ever with Nginx Clément Nedelcu BIRMINGHAM - MUMBAI www.it-ebooks.info Nginx HTTP Server... 54 55 56 57 58 59 Httperf 59 Autobench 61 OpenWebLoad 62 [ ii ] www.it-ebooks.info Table of Contents Upgrading Nginx gracefully Summary 64 64 Chapter 3: HTTP Configuration 65 HTTP Core module... of Nginx and progressively understand why so many administrators have decided to place their trust in this new HTTP server, often at the expense of Apache There are many aspects in which Nginx

Ngày đăng: 12/03/2019, 15:00

Mục lục

    Setting up the prerequisites

    GCC – GNU Compiler Collection

    Modules enabled by default

    Modules disabled by default

    About the prefix switch

    Regular HTTP and HTTPS servers

    Make sure you installed the prerequisites

    Directories exist and are writable

    Controlling the Nginx service

    Starting and stopping the daemon

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan