The Linux-related nginx

First, compile nginx installation:

A download source package.
 Wget -C HTTPS: // nginx.org/download/nginx-1.9.6.tar.gz 
2 . Decompressor source
 the tar -zxvf nginx- 1.9 . . 6 . The tar .gz
 . 3 configuration, compiler installation. nginx open state monitoring 
. / the configure --prefix = / opt / nginx / --with-http_ssl_module --with- http_stub_status_module 
 the make && the make  install  
4 . start nginx, enter sbin directory, find nginx start command 
cd sbin 
. / nginx # start 
. / nginx - S STOP # close 
. after / nginx -s reload # GR modified nginx.conf, you can not restart the service, load the new configuration

Two, nginx configure the relevant parameters:

nginx configure arguments 
following is a source code program nginx configure parameters:

 --prefix = point installation directory.
--sbin-path = Specifies the execution of the program file location.
--modules-path = storage path specified third-party modules.
--conf-path = specified configuration file storage location.
--error-log-path = specifies the error log storage position.
--pid-path = Specifies the pid file location.
--lock-path = Specifies the lock file location.
--user = non-privileged user to specify the program is running.
--group = non-privileged user group to specify when the program runs.
--builddir = points to the build directory.
--with- rtsig_module enable rtsig module support.
--with-select_module enable select module supports a polling approach is not recommended for use in high concurrency environments, disabled: - without- select_module.
--with- poll_module enable the poll module supports the same functions and select, it is not recommended for use in high concurrency environments.
--with-Enabling thread pool threads support.
--with- File - aio enabled file aio support.
--with- http_ssl_module enable https support.
--with- http_v2_module enable ngx_http_v2_module support.
--with- ipv6 enable ipv6 support.
--with- http_realip_module allowed to change from the request header in the client the ip address, the default is off.
--with- http_addition_module enabled ngix_http_additon_mdoule support (as a filter output, in response to the request in portions).
--with - http_xslt_module enabled ngx_http_xslt_module support, filtering XML conversion request.
--with- http_image_filter_mdoule enabled ngx_http_image_filter_module support, transfer JPEG \ GIF \ PNG picture of a filter, not enabled by default, you need to install gd library.
--with- http_geoip_module enabled ngx_http_geoip_module support for creating client-based MaxMind GeoIP binary file to match the client IP address ngx_http_geoip_module variables.
--with-http_sub_module enabled ngx_http_sub_module support, allowing text to replace some nginx response in some other text.
--with- http_dav_module enabled ngx_http_dav_module support, increase PUT, DELETE, MKCOL create a collection, COPY and MOVE methods, it is off by default, need to build on.
--with- http_flv_module enabled ngx_http_flv_module support, seeks to provide a memory-based file offset of time.
--with- http_mp4_module enabled ngx_http_mp4_module support, enable support for mp4 video file type.
--with- http_gzip_static_module enabled ngx_http_gzip_static_module support, support online real-time compression output data stream.
--with- http_random_index_module enabled ngx_http_random_index_module support, randomly selected from a directory index directory.
--with- http_secure_link_module enabled ngx_http_secure_link_module support, calculation and inspection requirements necessary for a secure link URL.
--with- http_degradation_module support enabled ngx_http_degradation_module allowed to return to 204 or 444 code under low memory conditions.
--with-http_stub_status_module enable ngx_http_stub_status_module nginx supports viewing the status page.
--without-http_charset_module ngx_http_charset_module disable this module, can be converted between the character set to another character converted from UTF8 or other character conversion into UTF8. It is only from server to client direction, only one-byte character can be converted.
--without-http_gzip_module disabled ngx_http_gzip_module support, with --with- as http_gzip_static_module function.
--without- http_ssi_module disabled ngx_http_ssi_module support, provided at the input of a processing filter comprises a file server (SSI) of.
--without- http_userid_module ngx_http_userid_module support disabled, the client module to determine cookies subsequent requests.
--without- http_access_module disabled ngx_http_access_module support provides host-based access control ip address.
--without- http_auth_basic_module disabled ngx_http_auth_basic_module support, you can use the user name and password authentication methods to authenticate the site or in part.
--without-http_autoindex_module disabled ngx_http_authindex_module, the module is used to issue a request when ngx_http_index_module module does not find the index file, used to automatically generate directory listing.
--without- http_geo_module disabled ngx_http_geo_module support, this module is used to create a variable dependent on the client's ip.
--without- http_map_module disabled ngx_http_map_module support, use any of the key, set the value of the configuration variable.
--without- http_split_clients_module disabled ngx_http_split_clients_module support, the module for the user based on ip addresses, headers, cookies divided user.
--without- http_referer_module disabled ngx_http_referer_modlue support, the module is used to filter requests, Referer header value is not correct request.
--without- http_rewrite_module disabled ngx_http_rewrite_module support. This module allows the use of regular expressions changed URI, and not to select the configuration according to the steering and variable. If this option is set at the server level, it will take effect before the location, location but if there are further rewrite rules, location rules section will still be executed. If this URI rewrite rules location because part of the cause, then the location will again be executed as part of a new URI, this cycle will be executed 10 times, the last returned a 500 error.
--without-http_proxy_module disabled ngx_http_proxy_module support, http proxy function.
--without- http_fastcgi_module disabled ngx_http_fastcgi_module support, the module allows interaction with nginx fastcgi process, and to control the fastcgi process works by passing parameters.
--without- http_uwsgi_module disabled ngx_http_uwsgi_module support, the module for use uwsgi agreement, uwsgi server-related.
--without- http_scgi_module disabled ngx_http_scgi_module support, like fastcgi, but also http interface standard applications and services.
--without- http_memcached_module disabled ngx_http_memcached support, to provide simple caching to improve system efficiency.
--without- http_limit_conn_module disabled ngx_http_limit_conn_module support, the module may be connected to the number of concurrent sessions is limited according to conditions.
--without- http_limit_req_module disabled ngx_limit_req_module support, the module may be implemented for a limited number of requests address.
--without-http_empty_gif_module disabled ngx_http_empty_gif_module support, a resident of the module in memory * 1 transparent gif image 1, can be very quickly called.
--without- http_browser_module disabled ngx_http_browser_mdoule support, value creation depends on the request header. If the browser is a modern, then the value is equal to $ modern_browser modern_browser_value; and if the browser is old, equal to the $ ancient_browser $ ancient_browser_value command value allocated; if the browser is MSIE, MSIE equal to the $ 1.
--without- http_upstream_ip_hash_module disabled ngx_http_upstream_ip_hash_module support, the module for simple load balancing.
--with- http_perl_module enabled ngx_http_perl_module support, nginx can use it to make calls perl perl directly or through ssi.
--with-perl_modules_path = set perl module path
 --with- perl = set perl library file path
 --http-log-path = set access log path
 --http-client-body-temp- path = setting http client requesting a temporary file path
 --http-proxy-temp-path = set http proxy temporary file path
 --http-fastcgi-temp-path =Set http fastcgi temporary file path
 --http-uwsgi-temp-path = setting http scgi temporary file path
 --http-scgi-temp-path = setting http scgi temporary file path
 --without- HTTP http server function is disabled
 http----without Cache disable http cache function
 --with- mail-enabled POP3, IMAP4, SMTP proxy module
 --with- mail_ssl_module enable ngx_mail_ssl_module support
 --without- mail_pop3_module disabled pop3 protocol.
--without- mail_iamp_module disabled iamp agreement.
--without- mail_smtp_module disabled smtp protocol.
--with- google_perftools_module enabled ngx_google_perftools_mdoule support, debugging can be used to analyze performance bottlenecks.
--with- cpp_test_module enable ngx_cpp_test_module support.
--add-module = specify an external module path, enable support for external modules.
--with- CC = point C compiler path.
--with- CPP = point C preprocessor path.
--with- CC -opt = C compiler provided parameter specifies --with- CC -opt = " -I / usr / LCAL / the include " , if the use of select () function, but also need to specify the number of file simultaneously - -with- CC -opt = " -D FD_SETSIZE = 2048 " . (The PCRE library)
 --with- LD -opt = Connected file parameters specify --with- LD -opt = " -L / usr / local / lib " . (The PCRE library)
 --with-opt = CPU- specified compiled CPU type, such as Pentium, PentiumPro, ... AMD64, ppc64 ...
 --without- pcre disable the pcre library.
--with- pcre pcre library enabled.
--with-pcre = point pcre library directory.
--with-pcre-opt = set of additional parameters pcre library at compile time.
--with-md5 = point md5 library directory.
--with-md5-opt = set of additional parameters md5 library compile time.
-MD5---with ASM using md5 assembler source.
--with-sha1 = point sha1 library directory.
--with-sha1-opt = setting additional parameters to sha1 library compile time.
sha1----with ASM using sha1 assembler source.
--with-zlib = point zlib library directory.
--with-zlib-opt = set to zlib additional parameters at compile time.
--with-zlib-asm = specified CPU optimized assembler source.
--with- libatomic provide a framework for the realization of the memory updating operation atoms.
--with-libatomic = point of libatomic_ops installation directory.
--with-openssl = point openssl installation directory.
--with-openssl-opt =Openssl to set additional parameters at compile time.
--with- debug Enable debug log. 

nginx configure arguments

Three, nginx of log_format Detailed format:  

    PS: Nginx log related instructions are mainly two, one is log_format, used to set the log format is an additional access_log, used to store the path for the log file, type, cache size, etc., generally on the default master configuration file Nginx /etc/nginx/nginx.conf.
 

 

Nginx has a lot of log_format optional parameter is used to indicate the active state of the server, the default is:
'$ REMOTE_ADDR - $ REMOTE_USER [$ time_local] "$ Request"'
'$ Status $ body_bytes_sent "$ HTTP_REFERER"'
' "$ HTTP_USER_AGENT "" $ http_x_forwarded_for " ';

 

 

parameter Explanation Examples
$remote_addr Client Address 219.227.111.255
$remote_user Client User Name
$time_local Access time and time zone 18/Jul/2014:17:00:01 +0800
$request HTTP protocol and the request URI “GET /article-10000.html HTTP/1.1”
$http_host Request address, the browser address you entered (IP or domain name) www.ha97.com
198.98.120.87
$status HTTP request status 200
$upstream_status upstream state 200
$body_bytes_sent Sent to the client file content size 1547
$http_referer Jump Source url https://www.google.com/
$http_user_agent User terminal browser and other information “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; GTB7.0; .NET4.0C;
$ssl_protocol SSL protocol version TLSv1
$ssl_cipher Data exchange algorithm RC4-SHA
$upstream_addr Background upstream of address, host address really provide services 10.36.10.80:80
$request_time The total time for the entire request 0.165
$upstream_response_time Request process, upstream response time 0.002

four,

Guess you like

Origin www.cnblogs.com/shangguanruoling/p/11833559.html