Linux Nginx compile installation tutorials and compile parameters detailed _nginx

Source: Internet
Author: User
Tags curl imap install openssl md5 memory usage openssl openssl library sha1

First, the necessary software preparation
1. Install Pcre

In order to support the rewrite function, we need to install Pcre

Copy Code code as follows:
# yum Install pcre*/If you've already installed, please skip this step

2. Install OpenSSL

Requires SSL support, skip this step if SSL support is not required

Copy Code code as follows:
# yum Install openssl*

3.gzip Class Library Installation

Copy Code code as follows:
Yum Install zlib Zlib-devel

4. Install wget

Download Nginx use, if already installed, skip this step

Copy Code code as follows:
# yum Install wget

Second, install Nginx

1. Download

Copy Code code as follows:
wget http://nginx.org/download/nginx-1.7.0.tar.gz



2. Decompression


Copy Code code as follows:

TAR-ZXVF nginx-1.7.0.tar.gz



3. Compile and install


Execute the following command:


Copy Code code as follows:

# CD nginx-1.7.0
#./configure--prefix=/usr/local/nginx-1.7.0 \
--with-http_ssl_module--with-http_spdy_module \
--with-http_stub_status_module--with-pcre



–with-http_stub_status_module: Support nginx status Query


–with-http_ssl_module: Support HTTPS


–with-http_spdy_module: Support the spdy of Google, want to understand please Baidu Spdy, this must have the support of SSL


–with-pcre: In order to support the rewrite rewrite function, it is necessary to develop pcre

The final output of the following content, said configure OK.

Copy Code code as follows:



Checking for zlib library ... found


Creating Objs/makefile


Configuration Summary


+ Using System PCRE Library


+ Using System OpenSSL Library


+ md5:using OpenSSL Library


+ sha1:using OpenSSL Library


+ Using System zlib Library


Nginx path prefix: "/usr/local/nginx-1.7.0"


Nginx binary file: "/usr/local/nginx-1.7.0/sbin/nginx"


Nginx configuration prefix: "/usr/local/nginx-1.7.0/conf"


Nginx configuration file: "/usr/local/nginx-1.7.0/conf/nginx.conf"


Nginx pid file: "/usr/local/nginx-1.7.0/logs/nginx.pid"


Nginx error log file: "/usr/local/nginx-1.7.0/logs/error.log"


Nginx HTTP access log file: "/usr/local/nginx-1.7.0/logs/access.log"


Nginx HTTP client request body Temporary files: "Client_body_temp"


Nginx HTTP proxy temporary files: "Proxy_temp"


Nginx http fastcgi temporary files: "Fastcgi_temp"


Nginx http Uwsgi temporary files: "Uwsgi_temp"


Nginx http scgi temporary files: "Scgi_temp"


# Make/Confirm your server has install make, if not installed please perform yum install





# make Install

Third, start, close, reset Nginx

Start: Direct execution of the following command, Nginx started, do not need to change any configuration files, Nginx Configure multiple domain name Virtual host please refer to the following articles.

Copy Code code as follows:
/usr/local/nginx-1.7.0/sbin/nginx



Try access: Read Web information directly using the Curl command


Copy Code code as follows:

[Root@ns conf]
# curl-s http://localhost | grep nginx.com
Nginx.com.



Shut down:


Copy Code code as follows:
/usr/local/nginx-1.7.0/sbin/nginx-s stop



Reset: When you have modified the configuration file, you only need to reload the following


Copy Code code as follows:
/usr/local/nginx-1.7.0/sbin/nginx-s Reload



The entire Nginx installation is over here.

Four, Nginx compile parameter detailed explanation

Copy Code code as follows:



–prefix= point to installation directory


–sbin-path Point (Execution) program file (Nginx)


–conf-path= point to configuration file (nginx.conf)


–error-log-path= point to error log directory


–pid-path= point to PID file (nginx.pid)


–lock-path= point to lock File (nginx.lock) (Install file lock, prevent the installation file from being exploited by others, or do it by mistake.) )


–user= Specifies the non privileged user of the program at run time


–group= Specifies the unprivileged user group when the program is run


–builddir= point to compile directory


–with-rtsig_module Enable Rtsig module support (Live signal)


–with-select_module Enable Select module Support (a polling mode that is not recommended for use in a high Load environment) disable: –without-select_module


–with-poll_module Enable poll module support (same function as SELECT, same as Select feature, for a polling mode, not recommended for high load environment)


–with-file-aio Enable file Aio support (an APL file transfer format)


–with-ipv6 Enable IPv6 support


–with-http_ssl_module Enable Ngx_http_ssl_module Support (make support for HTTPS requests, install OpenSSL required)


–with-http_realip_module Enable Ngx_http_realip_module Support (this module allows you to change the IP address value of the client from the request header, which is off by default)


–with-http_addition_module Enable Ngx_http_addition_module support (as an output filter, support for incomplete buffering, partial response request)


–with-http_xslt_module Enable Ngx_http_xslt_module support (Filter transform XML request)


–with-http_image_filter_module enables Ngx_http_image_filter_module support (a filter that transmits jpeg/gif/png pictures) (default is not enabled.) GD Library to use)


–with-http_geoip_module Enable Ngx_http_geoip_module Support (this module creates ngx_http_geoip_module variables that are based on client IP addresses that match the Maxmind GeoIP binaries)


–with-http_sub_module Enable Ngx_http_sub_module support (allow some text in the Nginx response to be replaced with some other text)


–with-http_dav_module Enable Ngx_http_dav_module Support (add Put,delete,mkcol: Create collection, copy, and Move methods) by default to shutdown, need to compile to open


–with-http_flv_module Enable Ngx_http_flv_module Support (provides a time based offset file for memory usage)


–with-http_gzip_static_module Enable Ngx_http_gzip_static_module support (online real-time compressed output data stream)


–with-http_random_index_module Enable Ngx_http_random_index_module support (random selection of a directory index from the directory)


–with-http_secure_link_module Enable ngx_http_secure_link_module Support (secure link URLs required to compute and check requirements)


–with-http_degradation_module Enable Ngx_http_degradation_module Support (allows 204 or 444 yards to be returned in case of low memory)


–with-http_stub_status_module Enable Ngx_http_stub_status_module support (get nginx working status since last startup)


–without-http_charset_module disables Ngx_http_charset_module support (recoding Web pages, but only in one Direction – server to client, and only one byte encoding can be recoding)


–without-http_gzip_module Disables Ngx_http_gzip_module support (this module is the same as the-with-http_gzip_static_module feature)


–without-http_ssi_module Disables Ngx_http_ssi_module support (this module provides a filter for processing server containing files (SSI) at the input end, and the current list of support SSI commands is incomplete)


–without-http_userid_module Disables Ngx_http_userid_module support (this module is used to process cookies that determine client subsequent requests)


–without-http_access_module Disables Ngx_http_access_module support (this module provides a simple host-based access control.) Allow/deny based on IP address)


–without-http_auth_basic_module disables Ngx_http_auth_basic_module (the module is a user name and password based on the HTTP Basic authentication method to protect your site or some of its content)


–without-http_autoindex_module Disables disable Ngx_http_autoindex_module support (this module is used to automatically generate directory listings, only in ngx_http_index_ The module module makes a request when the index file is not found. )


–without-http_geo_module Disable Ngx_http_geo_module support (create variables with values that depend on the client's IP address)


–without-http_map_module Disable Ngx_http_map_module Support (configure variables with any key/value pair settings)


–without-http_split_clients_module disables Ngx_http_split_clients_module support, which is used to divide users based on certain conditions. Conditions such as: IP address, header, cookies, etc.)


–without-http_referer_module Disables disable Ngx_http_referer_module support (this module is used to filter requests and reject requests with incorrect referer values in the header)


–without-http_rewrite_module disables Ngx_http_rewrite_module support, which allows the use of regular expressions to change URIs, and to shift to and select configurations based on variables. If you set this option at the server level, they will take effect before location. If there are further rewriting rules in location, the rules of the location section will still be executed. If this URI rewrite is due to the location part of the rule, then the location part will be executed again as the new URI. The loop executes 10 times, and then Nginx returns a 500 error. )


–without-http_proxy_module Disable Ngx_http_proxy_module support (for proxy servers)


–without-http_fastcgi_module disables Ngx_http_fastcgi_module support, which allows Nginx to interact with fastcgi processes and to control fastcgi process work by passing parameters. ) fastcgi a resident type of public gateway interface.


–without-http_uwsgi_module Disables Ngx_http_uwsgi_module support (this module is used for medical UWSGI protocol, UWSGI server-related)


–without-http_scgi_module disables Ngx_http_scgi_module support, which is used to enable SCGI protocol support, and the SCGI protocol is an alternative to CGI protocols. It is an interface standard for applications and HTTP services. It's a bit like fastcgi but his design is easier to implement. )


–without-http_memcached_module Disables Ngx_http_memcached_module support (this module is used to provide a simple cache to improve system efficiency)


-without-http_limit_zone_module disables Ngx_http_limit_zone_module support (the module can control the number of concurrent connections to the session for the condition)


–without-http_limit_req_module Disables Ngx_http_limit_req_module support (this module allows you to limit the number of requests to an address with a given session or a specific event)


–without-http_empty_gif_module Disables Ngx_http_empty_gif_module support (this module resides in memory in a 1*1 transparent GIF image that can be invoked very quickly)


–without-http_browser_module disables Ngx_http_browser_module support, which is used to create values that depend on the request header. If the browser is modern, the $modern_browser equals the value assigned by the modern_browser_value instruction; If the browser is old, $ancient_browser equals ancient_browser_ Value assigned by the MSIE, or $msie equal to 1 if the browser is any version in the


–without-http_upstream_ip_hash_module Disable Ngx_http_upstream_ip_hash_module Support (this module is for simple load balancing)


–with-http_perl_module Enable Ngx_http_perl_module Support (This module allows Nginx to directly use Perl or Invoke Perl via SSI)


–with-perl_modules_path= Set Perl module path


–with-perl= Set the Perl library file path


–http-log-path= Set Access log path


–http-client-body-temp-path= Set HTTP client request temp file path


–http-proxy-temp-path= Set HTTP Proxy temp file path


–http-fastcgi-temp-path= set HTTP fastcgi temporary file path


–http-uwsgi-temp-path= set HTTP uwsgi temporary file path


–http-scgi-temp-path= set HTTP scgi temporary file path


-without-http Disable HTTP Server features


–without-http-cache Disable HTTP Cache feature


–with-mail Enable POP3/IMAP4/SMTP Agent module support


–with-mail_ssl_module Enable Ngx_mail_ssl_module Support


–without-mail_pop3_module disables the POP3 protocol (POP3, the 3rd version of the Post Office Protocol), which is a protocol that prescribes how a personal computer connects to a mail server on the Internet to send and receive mail. is the first offline protocol standard for Internet e-mail, which allows users to store messages on the local host from the server and delete or save messages on the mail server based on the actions of the client POP3. The POP3 protocol is a member of the TCP/IP protocol family and is used primarily to support the use of client remote management of e-mail messages on the server.


–without-mail_imap_module disables the IMAP protocol, a message acquisition protocol. Its main function is that the mail client can get the message from the mail server through this protocol, download the message, etc. The IMAP protocol runs on top of the TCP/IP protocol and uses a port of 143. The main difference between it and the POP3 protocol is that the user can not download all the mail, and can directly operate the Mail on the server through the client. )


–without-mail_smtp_module disables the SMTP protocol (SMTP, the Simple Mail Transfer Protocol, which is a set of rules for sending messages from the source address to the destination to control how the letters are relayed.) The SMTP protocol belongs to the TCP/IP protocol family, which helps each computer find the next destination when sending or relaying letters. )


–with-google_perftools_module Enable Ngx_google_perftools_module support (Tune trial, profiling program performance bottlenecks)


–with-cpp_test_module Enable Ngx_cpp_test_module Support


–add-module= Enable external module support


–with-cc= point to C compiler path


–with-cpp= point to C preprocessing path


–with-cc-opt= set the C compiler parameter (Pcre library, you need to specify –with-cc-opt= "-i/usr/local/include", if you use the Select () function, you need to increase the number of file descriptors at the same time, you can pass the –with-cc- Opt= "-D fd_setsize=2048" specified. )


–with-ld-opt= sets the connection file parameters. (Pcre library, you need to specify –with-ld-opt= "-l/usr/local/lib".) )


–with-cpu-opt= Specifies the compiled CPU, and the available values are: Pentium, Pentiumpro, Pentium3, Pentium4, Athlon, Opteron, AMD64, Sparc32, SPARC64, PPC64


–without-pcre Disable Pcre Library


–with-pcre Enable Pcre Library


–with-pcre= point to Pcre library file directory


–with-pcre-opt= set additional parameters for the Pcre library at compile time


–with-md5= points to the MD5 library file directory (Message digest algorithm fifth edition to provide message integrity protection)


–with-md5-opt= set additional parameters for the MD5 library at compile time


–WITH-MD5-ASM Use MD5 Assembly source


–with-sha1= point to SHA1 Library directory (digital Signature algorithm, mainly for digital signature)


–with-sha1-opt= set additional parameters for the SHA1 library at compile time


–with-sha1-asm Use SHA1 Assembly source


–with-zlib= point to zlib Library directory


–with-zlib-opt= set additional parameters for zlib at compile time


–with-zlib-asm= is optimized for the specified CPU using a zlib assembly source, with a CPU type of Pentium, Pentiumpro


–with-libatomic provides a framework for the implementation of the update operation of atomic memory


–with-libatomic= point to Libatomic_ops installation directory


–with-openssl= point to OpenSSL installation directory


–with-openssl-opt set additional parameters for OpenSSL at compile time


–with-debug enable the debug log

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.