Nginx依赖于多个库,所以在安装Nginx之前需要确保Linux操作系统中已经安装了这些依赖库。
安装依赖库:
yum -y install --skip-broken gcc gcc-c++ autoconf automake yum -y install --skip-broken zlib zlib-devel openssl-devel pcre-devel
如果操作系统不能联网,可以使用安装光盘,依照如下顺序安装依赖包。
Xshell for Xmanager Enterprise 3.0 (Build 0281) Copyright (c) 2002-2010 NetSarang Computer, Inc. All rights reserved. Type `help' to learn how to use Xshell prompt. Xshell:\> Connecting to 192.168.253.129:22... Connection established. Escape character is '^@]'. Last login: Sat Nov 23 19:34:16 2013 from 192.168.253.1 [root@localhost ~]# cd /media/ [root@localhost media]# ll total 8 dr-xr-xr-x. 12 root root 8192 Jun 14 2012 RHEL_6.3 x86_64 Disc 1 [root@localhost media]# cd RHEL_6.3\ x86_64\ Disc\ 1/ [root@localhost RHEL_6.3 x86_64 Disc 1]# ll total 2885 dr-xr-xr-x. 3 root root 2048 Jun 14 2012 EFI -r--r--r--. 3 root root 8794 Sep 3 2010 EULA -r--r--r--. 3 root root 18092 Jun 30 2010 GPL dr-xr-xr-x. 3 root root 2048 Jun 14 2012 HighAvailability dr-xr-xr-x. 3 root root 2048 Jun 14 2012 images dr-xr-xr-x. 2 root root 2048 Jun 14 2012 isolinux dr-xr-xr-x. 3 root root 2048 Jun 14 2012 LoadBalancer -r--r--r--. 2 root root 114 Jun 14 2012 media.repo dr-xr-xr-x. 2 root root 659456 Jun 14 2012 Packages -r--r--r--. 2 root root 16435 Sep 2 2010 README -r--r--r--. 3 root root 118323 May 28 2012 RELEASE-NOTES-as-IN.html -r--r--r--. 3 root root 95683 May 28 2012 RELEASE-NOTES-bn-IN.html -r--r--r--. 3 root root 74603 May 28 2012 RELEASE-NOTES-de-DE.html -r--r--r--. 3 root root 72243 May 29 2012 RELEASE-NOTES-en-US.html -r--r--r--. 3 root root 73728 May 29 2012 RELEASE-NOTES-es-ES.html -r--r--r--. 3 root root 77579 May 29 2012 RELEASE-NOTES-fr-FR.html -r--r--r--. 3 root root 116218 May 29 2012 RELEASE-NOTES-gu-IN.html -r--r--r--. 3 root root 114109 May 29 2012 RELEASE-NOTES-hi-IN.html -r--r--r--. 3 root root 73390 May 29 2012 RELEASE-NOTES-it-IT.html -r--r--r--. 3 root root 83916 May 29 2012 RELEASE-NOTES-ja-JP.html -r--r--r--. 3 root root 130026 May 29 2012 RELEASE-NOTES-kn-IN.html -r--r--r--. 3 root root 75107 May 29 2012 RELEASE-NOTES-ko-KR.html -r--r--r--. 3 root root 140361 May 29 2012 RELEASE-NOTES-ml-IN.html -r--r--r--. 3 root root 116906 May 29 2012 RELEASE-NOTES-mr-IN.html -r--r--r--. 3 root root 120033 May 29 2012 RELEASE-NOTES-or-IN.html -r--r--r--. 3 root root 106899 May 29 2012 RELEASE-NOTES-pa-IN.html -r--r--r--. 3 root root 72058 May 29 2012 RELEASE-NOTES-pt-BR.html -r--r--r--. 3 root root 80711 May 29 2012 RELEASE-NOTES-ru-RU.html -r--r--r--. 3 root root 5125 May 5 2010 RELEASE-NOTES-si-LK.html -r--r--r--. 3 root root 69700 May 29 2012 RELEASE-NOTES-ta-IN.html -r--r--r--. 3 root root 118830 May 29 2012 RELEASE-NOTES-te-IN.html -r--r--r--. 3 root root 135476 May 29 2012 RELEASE-NOTES-zh-CN.html -r--r--r--. 3 root root 136075 May 29 2012 RELEASE-NOTES-zh-TW.html dr-xr-xr-x. 2 root root 4096 Jun 14 2012 repodata dr-xr-xr-x. 3 root root 2048 Jun 14 2012 ResilientStorage -r--r--r--. 3 root root 3375 May 31 2012 RPM-GPG-KEY-redhat-beta -r--r--r--. 3 root root 3211 May 31 2012 RPM-GPG-KEY-redhat-release dr-xr-xr-x. 3 root root 2048 Jun 14 2012 ScalableFileSystem dr-xr-xr-x. 3 root root 2048 Jun 14 2012 Server -r--r--r--. 1 root root 9435 Jun 14 2012 TRANS.TBL [root@localhost RHEL_6.3 x86_64 Disc 1]# c Packages/ -bash: c: command not found [root@localhost RHEL_6.3 x86_64 Disc 1]# ll total 2885 dr-xr-xr-x. 3 root root 2048 Jun 14 2012 EFI -r--r--r--. 3 root root 8794 Sep 3 2010 EULA -r--r--r--. 3 root root 18092 Jun 30 2010 GPL dr-xr-xr-x. 3 root root 2048 Jun 14 2012 HighAvailability dr-xr-xr-x. 3 root root 2048 Jun 14 2012 images dr-xr-xr-x. 2 root root 2048 Jun 14 2012 isolinux dr-xr-xr-x. 3 root root 2048 Jun 14 2012 LoadBalancer -r--r--r--. 2 root root 114 Jun 14 2012 media.repo dr-xr-xr-x. 2 root root 659456 Jun 14 2012 Packages -r--r--r--. 2 root root 16435 Sep 2 2010 README -r--r--r--. 3 root root 118323 May 28 2012 RELEASE-NOTES-as-IN.html -r--r--r--. 3 root root 95683 May 28 2012 RELEASE-NOTES-bn-IN.html -r--r--r--. 3 root root 74603 May 28 2012 RELEASE-NOTES-de-DE.html -r--r--r--. 3 root root 72243 May 29 2012 RELEASE-NOTES-en-US.html -r--r--r--. 3 root root 73728 May 29 2012 RELEASE-NOTES-es-ES.html -r--r--r--. 3 root root 77579 May 29 2012 RELEASE-NOTES-fr-FR.html -r--r--r--. 3 root root 116218 May 29 2012 RELEASE-NOTES-gu-IN.html -r--r--r--. 3 root root 114109 May 29 2012 RELEASE-NOTES-hi-IN.html -r--r--r--. 3 root root 73390 May 29 2012 RELEASE-NOTES-it-IT.html -r--r--r--. 3 root root 83916 May 29 2012 RELEASE-NOTES-ja-JP.html -r--r--r--. 3 root root 130026 May 29 2012 RELEASE-NOTES-kn-IN.html -r--r--r--. 3 root root 75107 May 29 2012 RELEASE-NOTES-ko-KR.html -r--r--r--. 3 root root 140361 May 29 2012 RELEASE-NOTES-ml-IN.html -r--r--r--. 3 root root 116906 May 29 2012 RELEASE-NOTES-mr-IN.html -r--r--r--. 3 root root 120033 May 29 2012 RELEASE-NOTES-or-IN.html -r--r--r--. 3 root root 106899 May 29 2012 RELEASE-NOTES-pa-IN.html -r--r--r--. 3 root root 72058 May 29 2012 RELEASE-NOTES-pt-BR.html -r--r--r--. 3 root root 80711 May 29 2012 RELEASE-NOTES-ru-RU.html -r--r--r--. 3 root root 5125 May 5 2010 RELEASE-NOTES-si-LK.html -r--r--r--. 3 root root 69700 May 29 2012 RELEASE-NOTES-ta-IN.html -r--r--r--. 3 root root 118830 May 29 2012 RELEASE-NOTES-te-IN.html -r--r--r--. 3 root root 135476 May 29 2012 RELEASE-NOTES-zh-CN.html -r--r--r--. 3 root root 136075 May 29 2012 RELEASE-NOTES-zh-TW.html dr-xr-xr-x. 2 root root 4096 Jun 14 2012 repodata dr-xr-xr-x. 3 root root 2048 Jun 14 2012 ResilientStorage -r--r--r--. 3 root root 3375 May 31 2012 RPM-GPG-KEY-redhat-beta -r--r--r--. 3 root root 3211 May 31 2012 RPM-GPG-KEY-redhat-release dr-xr-xr-x. 3 root root 2048 Jun 14 2012 ScalableFileSystem dr-xr-xr-x. 3 root root 2048 Jun 14 2012 Server -r--r--r--. 1 root root 9435 Jun 14 2012 TRANS.TBL [root@localhost RHEL_6.3 x86_64 Disc 1]# cd Packages/ [root@localhost Packages]# rpm -vih gcc-4.4.6-4.el6.x86_64.rpm warning: gcc-4.4.6-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: cloog-ppl >= 0.15 is needed by gcc-4.4.6-4.el6.x86_64 cpp = 4.4.6-4.el6 is needed by gcc-4.4.6-4.el6.x86_64 glibc-devel >= 2.2.90-12 is needed by gcc-4.4.6-4.el6.x86_64 [root@localhost Packages]# rpm -vih glib glib2-2.22.5-7.el6.i686.rpm glibc-common-2.12-1.80.el6.x86_64.rpm glib2-2.22.5-7.el6.x86_64.rpm glibc-devel-2.12-1.80.el6.i686.rpm glib2-devel-2.22.5-7.el6.i686.rpm glibc-devel-2.12-1.80.el6.x86_64.rpm glib2-devel-2.22.5-7.el6.x86_64.rpm glibc-headers-2.12-1.80.el6.x86_64.rpm glibc-2.12-1.80.el6.i686.rpm glibc-utils-2.12-1.80.el6.x86_64.rpm glibc-2.12-1.80.el6.x86_64.rpm glibmm24-2.22.1-1.el6.x86_64.rpm [root@localhost Packages]# rpm -vih glib glib2-2.22.5-7.el6.i686.rpm glibc-common-2.12-1.80.el6.x86_64.rpm glib2-2.22.5-7.el6.x86_64.rpm glibc-devel-2.12-1.80.el6.i686.rpm glib2-devel-2.22.5-7.el6.i686.rpm glibc-devel-2.12-1.80.el6.x86_64.rpm glib2-devel-2.22.5-7.el6.x86_64.rpm glibc-headers-2.12-1.80.el6.x86_64.rpm glibc-2.12-1.80.el6.i686.rpm glibc-utils-2.12-1.80.el6.x86_64.rpm glibc-2.12-1.80.el6.x86_64.rpm glibmm24-2.22.1-1.el6.x86_64.rpm [root@localhost Packages]# rpm -vih glib*.rpm warning: glib2-2.22.5-7.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: libfam.so.0 is needed by glib2-2.22.5-7.el6.i686 libselinux.so.1 is needed by glib2-2.22.5-7.el6.i686 libfreebl3.so is needed by glibc-2.12-1.80.el6.i686 libfreebl3.so(NSSRAWHASH_3.12.3) is needed by glibc-2.12-1.80.el6.i686 kernel-headers is needed by glibc-headers-2.12-1.80.el6.x86_64 kernel-headers >= 2.2.1 is needed by glibc-headers-2.12-1.80.el6.x86_64 libgd.so.2()(64bit) is needed by glibc-utils-2.12-1.80.el6.x86_64 [root@localhost Packages]# yum install gcc Loaded plugins: product-id, refresh-packagekit, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity Setting up Install Process No package gcc available. Error: Nothing to do [root@localhost Packages]# rpm -ivh kernel-headers-2.6.32-279.el6.x86_64.rpm warning: kernel-headers-2.6.32-279.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:kernel-headers ########################################### [100%] warning: glibc-headers-2.12-1.80.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:glibc-headers ########################################### [100%] [root@localhost Packages]# rpm -ivh glibc-devel-2.12-1.80.el6.x86_64.rpm warning: glibc-devel-2.12-1.80.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:glibc-devel ########################################### [100%] [root@localhost Packages]# rpm -ivh lib Display all 609 possibilities? (y or n) [root@localhost Packages]# rpm -ivh libgomp-4.4.6-4.el6.x86_64.rpm warning: libgomp-4.4.6-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] package libgomp-4.4.6-4.el6.x86_64 is already installed [root@localhost Packages]# rpm -ivh gcc-4.4.6-4.el6.x86_64.rpm warning: gcc-4.4.6-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: cloog-ppl >= 0.15 is needed by gcc-4.4.6-4.el6.x86_64 cpp = 4.4.6-4.el6 is needed by gcc-4.4.6-4.el6.x86_64 [root@localhost Packages]# rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm warning: ppl-0.10.2-11.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:ppl ########################################### [100%] [root@localhost Packages]# rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm warning: cloog-ppl-0.15.7-1.2.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:cloog-ppl ########################################### [100%] [root@localhost Packages]# rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm warning: mpfr-2.4.1-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:mpfr ########################################### [100%] [root@localhost Packages]# rpm -ivh cpp-4.4.6-4.el6.x86_64.rpm warning: cpp-4.4.6-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:cpp ########################################### [100%] [root@localhost Packages]# rpm -ivh gcc-4.4.6-4.el6.x86_64.rpm warning: gcc-4.4.6-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:gcc ########################################### [100%] [root@localhost Packages]# rpm -vih pcre-7.8-4.el6.x86_64.rpm warning: pcre-7.8-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] package pcre-7.8-4.el6.x86_64 is already installed [root@localhost Packages]# rpm -vih pcre-devel-7.8-4.el6.x86_64.rpm warning: pcre-devel-7.8-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:pcre-devel ########################################### [100%] [root@localhost Packages]# rpm -vih openssl-1.0.0-20.el6_2.5.x86_64.rpm warning: openssl-1.0.0-20.el6_2.5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] package openssl-1.0.0-20.el6_2.5.x86_64 is already installed [root@localhost Packages]# rpm -vih openssl-devel-1.0.0-20.el6_2.5.x86_64.rpm warning: openssl-devel-1.0.0-20.el6_2.5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: krb5-devel is needed by openssl-devel-1.0.0-20.el6_2.5.x86_64 zlib-devel is needed by openssl-devel-1.0.0-20.el6_2.5.x86_64 [root@localhost Packages]# rpm -vih krb5-devel-1.9-33.el6.x86_64.rpm warning: krb5-devel-1.9-33.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: keyutils-libs-devel is needed by krb5-devel-1.9-33.el6.x86_64 libcom_err-devel is needed by krb5-devel-1.9-33.el6.x86_64 libselinux-devel is needed by krb5-devel-1.9-33.el6.x86_64 [root@localhost Packages]# rpm -vih krb5-devel-1.9-33.el6.x86_64.rpm warning: krb5-devel-1.9-33.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: keyutils-libs-devel is needed by krb5-devel-1.9-33.el6.x86_64 libcom_err-devel is needed by krb5-devel-1.9-33.el6.x86_64 libselinux-devel is needed by krb5-devel-1.9-33.el6.x86_64 [root@localhost Packages]# rpm -vih libcom_err-devel-1.41.12-12.el6.x86_64.rpm warning: libcom_err-devel-1.41.12-12.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:libcom_err-devel ########################################### [100%] [root@localhost Packages]# rpm -vih libselinux-devel-2.0.94-5.3.el6.x86_64.rpm warning: libselinux-devel-2.0.94-5.3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: libsepol-devel >= 2.0.32-1 is needed by libselinux-devel-2.0.94-5.3.el6.x86_64 pkgconfig(libsepol) is needed by libselinux-devel-2.0.94-5.3.el6.x86_64 [root@localhost Packages]# rpm -vih keyutils-libs-devel-1.4-4.el6.x86_64.rpm warning: keyutils-libs-devel-1.4-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:keyutils-libs-devel ########################################### [100%] [root@localhost Packages]# rpm -vih pkgconfig-0.23-9.1.el6.x86_64.rpm warning: pkgconfig-0.23-9.1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] package pkgconfig-1:0.23-9.1.el6.x86_64 is already installed [root@localhost Packages]# rpm -vih libselinux-devel-2.0.94-5.3.el6.x86_64.rpm warning: libselinux-devel-2.0.94-5.3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: libsepol-devel >= 2.0.32-1 is needed by libselinux-devel-2.0.94-5.3.el6.x86_64 pkgconfig(libsepol) is needed by libselinux-devel-2.0.94-5.3.el6.x86_64 [root@localhost Packages]# rpm -vih libsepol-devel-2.0.41-4.el6.x86_64.rpm warning: libsepol-devel-2.0.41-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:libsepol-devel ########################################### [100%] [root@localhost Packages]# rpm -vih libselinux-devel-2.0.94-5.3.el6.x86_64.rpm warning: libselinux-devel-2.0.94-5.3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:libselinux-devel ########################################### [100%] [root@localhost Packages]# rpm -vih krb5-devel-1.9-33.el6.x86_64.rpm warning: krb5-devel-1.9-33.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:krb5-devel ########################################### [100%] [root@localhost Packages]# rpm -vih zlib-devel-1.2.3-27.el6.x86_64.rpm warning: zlib-devel-1.2.3-27.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:zlib-devel ########################################### [100%] [root@localhost Packages]# rpm -vih openssl-devel-1.0.0-20.el6_2.5.x86_64.rpm warning: openssl-devel-1.0.0-20.el6_2.5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:openssl-devel ########################################### [100%] [root@localhost Packages]# rpm -qa|grep gcc libgcc-4.4.6-4.el6.x86_64 gcc-4.4.6-4.el6.x86_64
对Nginx源码包的解压等,在此就不再 列出,直接进入Nginx的安装步骤。
获取Nginx安装选项帮助
[root@localhost nginx-1.4.4]# ./configure --help --help print this message --prefix=PATH set installation prefix --sbin-path=PATH set nginx binary pathname --conf-path=PATH set nginx.conf pathname --error-log-path=PATH set error log pathname --pid-path=PATH set nginx.pid pathname --lock-path=PATH set nginx.lock pathname --user=USER set non-privileged user for worker processes --group=GROUP set non-privileged group for worker processes --builddir=DIR set build directory --with-rtsig_module enable rtsig module --with-select_module enable select module --without-select_module disable select module --with-poll_module enable poll module --without-poll_module disable poll module --with-file-aio enable file AIO support --with-ipv6 enable IPv6 support --with-http_ssl_module enable ngx_http_ssl_module --with-http_spdy_module enable ngx_http_spdy_module --with-http_realip_module enable ngx_http_realip_module --with-http_addition_module enable ngx_http_addition_module --with-http_xslt_module enable ngx_http_xslt_module --with-http_image_filter_module enable ngx_http_image_filter_module --with-http_geoip_module enable ngx_http_geoip_module --with-http_sub_module enable ngx_http_sub_module --with-http_dav_module enable ngx_http_dav_module --with-http_flv_module enable ngx_http_flv_module --with-http_mp4_module enable ngx_http_mp4_module --with-http_gunzip_module enable ngx_http_gunzip_module --with-http_gzip_static_module enable ngx_http_gzip_static_module --with-http_random_index_module enable ngx_http_random_index_module --with-http_secure_link_module enable ngx_http_secure_link_module --with-http_degradation_module enable ngx_http_degradation_module --with-http_stub_status_module enable ngx_http_stub_status_module --without-http_charset_module disable ngx_http_charset_module --without-http_gzip_module disable ngx_http_gzip_module --without-http_ssi_module disable ngx_http_ssi_module --without-http_userid_module disable ngx_http_userid_module --without-http_access_module disable ngx_http_access_module --without-http_auth_basic_module disable ngx_http_auth_basic_module --without-http_autoindex_module disable ngx_http_autoindex_module --without-http_geo_module disable ngx_http_geo_module --without-http_map_module disable ngx_http_map_module --without-http_split_clients_module disable ngx_http_split_clients_module --without-http_referer_module disable ngx_http_referer_module --without-http_rewrite_module disable ngx_http_rewrite_module --without-http_proxy_module disable ngx_http_proxy_module --without-http_fastcgi_module disable ngx_http_fastcgi_module --without-http_uwsgi_module disable ngx_http_uwsgi_module --without-http_scgi_module disable ngx_http_scgi_module --without-http_memcached_module disable ngx_http_memcached_module --without-http_limit_conn_module disable ngx_http_limit_conn_module --without-http_limit_req_module disable ngx_http_limit_req_module --without-http_empty_gif_module disable ngx_http_empty_gif_module --without-http_browser_module disable ngx_http_browser_module --without-http_upstream_ip_hash_module disable ngx_http_upstream_ip_hash_module --without-http_upstream_least_conn_module disable ngx_http_upstream_least_conn_module --without-http_upstream_keepalive_module disable ngx_http_upstream_keepalive_module --with-http_perl_module enable ngx_http_perl_module --with-perl_modules_path=PATH set Perl modules path --with-perl=PATH set perl binary pathname --http-log-path=PATH set http access log pathname --http-client-body-temp-path=PATH set path to store http client request body temporary files --http-proxy-temp-path=PATH set path to store http proxy temporary files --http-fastcgi-temp-path=PATH set path to store http fastcgi temporary files --http-uwsgi-temp-path=PATH set path to store http uwsgi temporary files --http-scgi-temp-path=PATH set path to store http scgi temporary files --without-http disable HTTP server --without-http-cache disable HTTP cache --with-mail enable POP3/IMAP4/SMTP proxy module --with-mail_ssl_module enable ngx_mail_ssl_module --without-mail_pop3_module disable ngx_mail_pop3_module --without-mail_imap_module disable ngx_mail_imap_module --without-mail_smtp_module disable ngx_mail_smtp_module --with-google_perftools_module enable ngx_google_perftools_module --with-cpp_test_module enable ngx_cpp_test_module --add-module=PATH enable an external module --with-cc=PATH set C compiler pathname --with-cpp=PATH set C preprocessor pathname --with-cc-opt=OPTIONS set additional C compiler options --with-ld-opt=OPTIONS set additional linker options --with-cpu-opt=CPU build for the specified CPU, valid values: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, sparc32, sparc64, ppc64 --without-pcre disable PCRE library usage --with-pcre force PCRE library usage --with-pcre=DIR set path to PCRE library sources --with-pcre-opt=OPTIONS set additional build options for PCRE --with-pcre-jit build PCRE with JIT compilation support --with-md5=DIR set path to md5 library sources --with-md5-opt=OPTIONS set additional build options for md5 --with-md5-asm use md5 assembler sources --with-sha1=DIR set path to sha1 library sources --with-sha1-opt=OPTIONS set additional build options for sha1 --with-sha1-asm use sha1 assembler sources --with-zlib=DIR set path to zlib library sources --with-zlib-opt=OPTIONS set additional build options for zlib --with-zlib-asm=CPU use zlib assembler sources optimized for the specified CPU, valid values: pentium, pentiumpro --with-libatomic force libatomic_ops library usage --with-libatomic=DIR set path to libatomic_ops library sources --with-openssl=DIR set path to OpenSSL library sources --with-openssl-opt=OPTIONS set additional build options for OpenSSL --with-debug enable debug logging
编译nginx:
[root@localhost nginx-1.4.4]# ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --user=root --group=root --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --with-http_stub_status_module checking for OS + Linux 2.6.32-279.el6.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) checking for gcc -pipe switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for unistd.h ... found checking for inttypes.h ... found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for sched_setaffinity() ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... not found checking for dlopen() in libdl ... found checking for sched_yield() ... found checking for SO_SETFIB ... not found checking for SO_ACCEPTFILTER ... not found checking for TCP_DEFER_ACCEPT ... found checking for TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT ... found checking for TCP_INFO ... found checking for accept4() ... found checking for int size ... 4 bytes checking for long size ... 8 bytes checking for long long size ... 8 bytes checking for void * size ... 8 bytes checking for uint64_t ... found checking for sig_atomic_t ... found checking for sig_atomic_t size ... 4 bytes checking for socklen_t ... found checking for in_addr_t ... found checking for in_port_t ... found checking for rlim_t ... found checking for uintptr_t ... uintptr_t found checking for system byte ordering ... little endian checking for size_t size ... 8 bytes checking for off_t size ... 8 bytes checking for time_t size ... 8 bytes checking for setproctitle() ... not found checking for pread() ... found checking for pwrite() ... found checking for sys_nerr ... found checking for localtime_r() ... found checking for posix_memalign() ... found checking for memalign() ... found checking for mmap(MAP_ANON|MAP_SHARED) ... found checking for mmap("/dev/zero", MAP_SHARED) ... found checking for System V shared memory ... found checking for POSIX semaphores ... not found checking for POSIX semaphores in libpthread ... found checking for struct msghdr.msg_control ... found checking for ioctl(FIONBIO) ... found checking for struct tm.tm_gmtoff ... found checking for struct dirent.d_namlen ... not found checking for struct dirent.d_type ... found checking for sysconf(_SC_NPROCESSORS_ONLN) ... found checking for openat(), fstatat() ... found checking for getaddrinfo() ... found checking for PCRE library ... found checking for PCRE JIT support ... not found checking for OpenSSL library ... found 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" nginx binary file: "/usr/sbin/nginx" nginx configuration prefix: "/etc/nginx" nginx configuration file: "/etc/nginx/nginx.conf" nginx pid file: "/var/run/nginx/nginx.pid" nginx error log file: "/var/log/nginx/error.log" nginx http access log file: "/var/log/nginx/access.log" nginx http client request body temporary files: "/var/tmp/nginx/client" nginx http proxy temporary files: "/var/tmp/nginx/proxy" nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
make编译Nginx:
[root@localhost nginx-1.4.4]# make && make install make -f objs/Makefile make[1]: Entering directory `/home/nginx-1.4.4' cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
启动nginx:
ocalhost sbin]# nginx -c /etc/nginx/nginx.conf nginx: [emerg] mkdir() "/var/tmp/nginx/client" failed (2: No such file or directory) [root@localhost sbin]# mkdir /var/tmp/nginx/client -pv mkdir: created directory `/var/tmp/nginx' mkdir: created directory `/var/tmp/nginx/client' [root@localhost sbin]# nginx -c /etc/nginx/nginx.conf [root@localhost sbin]# ps aux |grep nginx root 51860 0.0 0.0 44384 980 ? Ss 00:14 0:00 nginx: master process nginx -c /etc/nginx/nginx.conf root 51861 0.0 0.0 44796 1568 ? S 00:14 0:00 nginx: worker process root 51863 0.0 0.0 103240 852 pts/4 S+ 00:14 0:00 grep nginx [root@localhost sbin]# netstat -tulnp |grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 51860/nginx
检测nginx配置 文件语法:
[root@localhost sbin]# /usr/sbin/nginx -t -c /etc/nginx/nginx.conf nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Nginx从容关闭:
[root@localhost sbin]# kill -QUIT $(cat /var/run/nginx/nginx.pid) [root@localhost sbin]# ps aux |grep nginx root 54225 0.0 0.0 103240 852 pts/4 S+ 00:34 0:00 grep nginx [root@localhost sbin]#
Nginx平滑重启: [root@localhost sbin]# kill -HUP $(cat /var/run/nginx/nginx.pid)
nginx的帮助:
[root@localhost ~]# nginx -h nginx version: nginx/1.4.4 Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help #显示帮助信息 -v : show version and exit #查看Nginx版本并退出 -V : show version and configure options then exit #显示Nginx版本和编译配置参数 -t : test configuration and exit #测试编译配置参数和退出 -q : suppress non-error messages during configuration testing #在配置测试期间抑制non-error消息 -s signal : send signal to a master process: stop, quit, reopen, reload #停止,退出,重开,重启 -p prefix : set prefix path (default: /usr/) #设置安装路径 -c filename : set configuration file (default: /etc/nginx/nginx.conf) #设置配置文件路径 -g directives : set global directives out of configuration file #设置全局指令配置文件
Nginx的配置文件nginx.conf:
[root@localhost nginx-1.4.4]# [root@localhost nginx-1.4.4]# cat /etc/nginx/nginx.conf #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { #默认路径为/usr/html/ root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } [root@localhost nginx-1.4.4]#