Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Nginx HTTP Server - Third Edition
Nginx HTTP Server - Third Edition
Nginx HTTP Server - Third Edition
Ebook765 pages5 hours

Nginx HTTP Server - Third Edition

Rating: 0 out of 5 stars

()

Read preview

About this ebook

By covering both the early setup stages and advanced topics, this book suits web administrators who interested in solutions to optimize their infrastructure, whether you are looking into replacing your existing web server software or integrating a new tool to cooperate with applications that are already up and running. If you, your visitors, and your operating system have been disappointed by Apache, this book is exactly what you need.
LanguageEnglish
Release dateNov 18, 2015
ISBN9781785285912
Nginx HTTP Server - Third Edition

Related to Nginx HTTP Server - Third Edition

Related ebooks

Programming For You

View More

Related articles

Reviews for Nginx HTTP Server - Third Edition

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Nginx HTTP Server - Third Edition - Nedelcu Clément

    www.packtpub.com/authors.

    Customer support

    Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

    Downloading the example code

    You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

    Errata

    Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

    To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

    Piracy

    Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

    Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.

    We appreciate your help in protecting our authors and our ability to bring you valuable content.

    Questions

    If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.

    Chapter 1. Downloading and Installing Nginx

    In this chapter, we will begin with the steps necessary to establish a functional setup of Nginx. This process is crucial for the smooth functioning of your web server. There are some required libraries and tools to install the program, some parameters that you will have to decide upon when compiling the binaries, and there may also be some configuration changes to perform on your system.

    This chapter covers the following topics:

    Downloading and installing the prerequisites to compile the Nginx binaries

    Downloading a suitable version of the Nginx source code

    Configuring Nginx compile-time options

    Controlling the application with an init script

    Configuring the system to launch Nginx automatically on startup

    A quick overview of the possibilities offered by the Nginx Plus platform

    Setting up the prerequisites

    We have chosen to download the source code of the application and compile it manually, as opposed to installing it using a package manager, such as Yum, Aptitude, or Yast. There are two reasons for this choice. First, the package may not be available in the enabled repositories of your Linux distribution. In addition, the repositories that offer to download and install Nginx automatically often contain outdated versions. More importantly, you need to configure a variety of significant compile-time options. As a result of this choice of manual setup, your system will require some tools and libraries for the compilation process.

    Depending on the optional modules that you select at compile time, you will perhaps need different prerequisites. You will be guided through the process of installing the most common ones, such as GCC, PCRE, zlib, and OpenSSL.

    Note

    If your operating system offers the possibility to install the Nginx package from a repository, and you are confident enough that the available version will suit all of your needs with the modules included by default, you could consider skipping this chapter altogether and simply run one the following commands. We still recommend getting the latest version and building it from source seeing as it contains the latest bug fixes and security patches. For a Debian-based operating system, run the following command:

    apt-get install nginx

    For Red Hat–based operating systems, use the following command:

    yum install nginx

    Alternatively, you can download and install prebuilt packages from the official Nginx website at http://www.nginx.org.

    The GNU Compiler Collection

    Nginx is a program written in C, so you will first need to install a compiler tool, such as the GNU Compiler Collection (GCC), on your system. GCC may already be present on your system, but if that is not the case, you will have to install it before going any further.

    Note

    GCC is a collection of free open source compilers for various languages: C, C++, Java, Ada, FORTRAN, and so on. It is the most commonly used compiler suite in the Linux world, and Windows versions are also available. It supports a vast number of processors such as x86, AMD64, PowerPC, ARM, MIPS, and more.

    First, make sure GCC isn't already installed on your system by running the following command:

    [alex@example.com ~]$ gcc

    If you get the following output, it means that GCC is correctly installed on your system and you can skip to the next section:

    gcc: no input files

    If you receive the following message, you will have to proceed with the installation of the compiler:

    ~bash: gcc: command not found

    GCC can be installed using the default repositories of your package manager. Depending on your distribution, the package manager will vary—yum for a Red Hat-based distribution, apt for Debian and Ubuntu, yast for SuSE Linux, and so on. Here is the typical way to proceed with the download and installation of the GCC package:

    [root@example.com ~]# yum groupinstall Development Tools

    If you use apt-get to install software packages, run the following command:

    [root@example.com ~]# apt-get install build-essentials

    If you use another package manager with a different syntax, you will probably find the documentation with the man utility. Either way, your package manager should be able to download and install GCC correctly after having solved the dependencies automatically. Note that this command not only installs GCC, it also proceeds with downloading and installing all common requirements to build applications from source, such as code headers and other compilation tools.

    The PCRE library

    The Perl Compatible Regular Expression (PCRE) library is required to compile Nginx. The Rewrite and HTTP core modules of Nginx use PCRE for the syntax of their regular expressions, as you will discover in later chapters. You will need to install two packages: pcre and pcre-devel. The first package provides the compiled version of the library, whereas the second one provides development headers and sources to compile projects, which are required in our case. Here are example commands that you can run in order to install both the

    Enjoying the preview?
    Page 1 of 1