Nginx(linux安装)

2023-05-16

Nginx(“engine x”)是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。
在高连接并发的情况下,Nginx是Apache服务器不错的替代品。

Nginx 安装
系统平台:CentOS release 6.6 (Final) 64位。

一、安装编译工具及库文件

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
[root@linux1 ~]# yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.cn99.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
base                                   | 3.7 kB     00:00     
extras                                 | 3.4 kB     00:00     
updates                                | 3.4 kB     00:00     
Setting up Install Process
Package zlib-1.2.3-29.el6.x86_64 already installed and latest version
Package gcc-c++-4.4.7-23.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package libtool.x86_64 0:2.2.6-15.5.el6 will be installed
--> Processing Dependency: automake >= 1.4 for package: libtool-2.2.6-15.5.el6.x86_64
--> Processing Dependency: autoconf >= 2.58 for package: libtool-2.2.6-15.5.el6.x86_64
---> Package make.x86_64 1:3.81-20.el6 will be updated
---> Package make.x86_64 1:3.81-23.el6 will be an update
---> Package openssl.x86_64 0:1.0.1e-15.el6 will be updated
---> Package openssl.x86_64 0:1.0.1e-58.el6_10 will be an update
---> Package openssl-devel.x86_64 0:1.0.1e-58.el6_10 will be installed
--> Processing Dependency: krb5-devel for package: openssl-devel-1.0.1e-58.el6_10.x86_64
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed
--> Running transaction check
---> Package autoconf.noarch 0:2.63-5.1.el6 will be installed
--> Processing Dependency: perl >= 5.005_03 for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl >= 5.005 for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl >= 5.000 for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(vars) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(strict) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(POSIX) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(IO::File) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(Getopt::Long) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(File::stat) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(File::Spec) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(File::Path) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(File::Find) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(File::Copy) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(File::Compare) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(File::Basename) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(Exporter) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(Errno) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(DynaLoader) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(Data::Dumper) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(Cwd) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl(Carp) for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: /usr/bin/perl for package: autoconf-2.63-5.1.el6.noarch
---> Package automake.noarch 0:1.11.1-4.el6 will be installed
---> Package krb5-devel.x86_64 0:1.10.3-65.el6 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.10.3-65.el6 for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: krb5-libs = 1.10.3-65.el6 for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.10.3-65.el6.x86_64
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be installed
--> Processing Dependency: keyutils-libs = 1.4-5.el6 for package: keyutils-libs-devel-1.4-5.el6.x86_64
---> Package krb5-libs.x86_64 0:1.10.3-10.el6_4.6 will be updated
---> Package krb5-libs.x86_64 0:1.10.3-65.el6 will be an update
---> Package libcom_err-devel.x86_64 0:1.41.12-24.el6 will be installed
--> Processing Dependency: libcom_err = 1.41.12-24.el6 for package: libcom_err-devel-1.41.12-24.el6.x86_64
---> Package libkadm5.x86_64 0:1.10.3-65.el6 will be installed
---> Package libselinux-devel.x86_64 0:2.0.94-7.el6 will be installed
--> Processing Dependency: libselinux = 2.0.94-7.el6 for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-7.el6.x86_64
---> Package perl.x86_64 4:5.10.1-144.el6 will be installed
--> Processing Dependency: perl-libs = 4:5.10.1-144.el6 for package: 4:perl-5.10.1-144.el6.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.10.1-144.el6.x86_64
--> Processing Dependency: perl(version) for package: 4:perl-5.10.1-144.el6.x86_64
--> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-144.el6.x86_64
--> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-144.el6.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.10.1-144.el6.x86_64
--> Running transaction check
---> Package keyutils-libs.x86_64 0:1.4-4.el6 will be updated
---> Package keyutils-libs.x86_64 0:1.4-5.el6 will be an update
---> Package libcom_err.x86_64 0:1.41.12-18.el6 will be updated
--> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-libs-1.41.12-18.el6.x86_64
--> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: libss-1.41.12-18.el6.x86_64
--> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-1.41.12-18.el6.x86_64
---> Package libcom_err.x86_64 0:1.41.12-24.el6 will be an update
---> Package libselinux.x86_64 0:2.0.94-5.3.el6_4.1 will be updated
--> Processing Dependency: libselinux = 2.0.94-5.3.el6_4.1 for package: libselinux-utils-2.0.94-5.3.el6_4.1.x86_64
---> Package libselinux.x86_64 0:2.0.94-7.el6 will be an update
---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be installed
---> Package perl-Module-Pluggable.x86_64 1:3.90-144.el6 will be installed
---> Package perl-Pod-Simple.x86_64 1:3.13-144.el6 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-144.el6.x86_64
---> Package perl-libs.x86_64 4:5.10.1-144.el6 will be installed
---> Package perl-version.x86_64 3:0.77-144.el6 will be installed
--> Running transaction check
---> Package e2fsprogs.x86_64 0:1.41.12-18.el6 will be updated
---> Package e2fsprogs.x86_64 0:1.41.12-24.el6 will be an update
---> Package e2fsprogs-libs.x86_64 0:1.41.12-18.el6 will be updated
---> Package e2fsprogs-libs.x86_64 0:1.41.12-24.el6 will be an update
---> Package libselinux-utils.x86_64 0:2.0.94-5.3.el6_4.1 will be updated
---> Package libselinux-utils.x86_64 0:2.0.94-7.el6 will be an update
---> Package libss.x86_64 0:1.41.12-18.el6 will be updated
---> Package libss.x86_64 0:1.41.12-24.el6 will be an update
---> Package perl-Pod-Escapes.x86_64 1:1.04-144.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package               Arch   Version           Repository
                                                         Size
==============================================================
Installing:
 libtool               x86_64 2.2.6-15.5.el6    base    564 k
 openssl-devel         x86_64 1.0.1e-58.el6_10  updates 1.2 M
 zlib-devel            x86_64 1.2.3-29.el6      base     44 k
Updating:
 make                  x86_64 1:3.81-23.el6     base    389 k
 openssl               x86_64 1.0.1e-58.el6_10  updates 1.5 M
Installing for dependencies:
 autoconf              noarch 2.63-5.1.el6      base    781 k
 automake              noarch 1.11.1-4.el6      base    550 k
 keyutils-libs-devel   x86_64 1.4-5.el6         base     29 k
 krb5-devel            x86_64 1.10.3-65.el6     base    504 k
 libcom_err-devel      x86_64 1.41.12-24.el6    base     33 k
 libkadm5              x86_64 1.10.3-65.el6     base    143 k
 libselinux-devel      x86_64 2.0.94-7.el6      base    137 k
 libsepol-devel        x86_64 2.0.41-4.el6      base     64 k
 perl                  x86_64 4:5.10.1-144.el6  base     10 M
 perl-Module-Pluggable x86_64 1:3.90-144.el6    base     41 k
 perl-Pod-Escapes      x86_64 1:1.04-144.el6    base     33 k
 perl-Pod-Simple       x86_64 1:3.13-144.el6    base    213 k
 perl-libs             x86_64 4:5.10.1-144.el6  base    579 k
 perl-version          x86_64 3:0.77-144.el6    base     52 k
Updating for dependencies:
 e2fsprogs             x86_64 1.41.12-24.el6    base    554 k
 e2fsprogs-libs        x86_64 1.41.12-24.el6    base    121 k
 keyutils-libs         x86_64 1.4-5.el6         base     20 k
 krb5-libs             x86_64 1.10.3-65.el6     base    675 k
 libcom_err            x86_64 1.41.12-24.el6    base     38 k
 libselinux            x86_64 2.0.94-7.el6      base    109 k
 libselinux-utils      x86_64 2.0.94-7.el6      base     82 k
 libss                 x86_64 1.41.12-24.el6    base     42 k

Transaction Summary
==============================================================
Install      17 Package(s)
Upgrade      10 Package(s)

Total download size: 19 M
Downloading Packages:
(1/27): autoconf-2.63-5.1.el6.noarch.r | 781 kB     00:00     
(2/27): automake-1.11.1-4.el6.noarch.r | 550 kB     00:00     
(3/27): e2fsprogs-1.41.12-24.el6.x86_6 | 554 kB     00:00     
(4/27): e2fsprogs-libs-1.41.12-24.el6. | 121 kB     00:00     
(5/27): keyutils-libs-1.4-5.el6.x86_64 |  20 kB     00:00     
(6/27): keyutils-libs-devel-1.4-5.el6. |  29 kB     00:00     
(7/27): krb5-devel-1.10.3-65.el6.x86_6 | 504 kB     00:00     
(8/27): krb5-libs-1.10.3-65.el6.x86_64 | 675 kB     00:00     
(9/27): libcom_err-1.41.12-24.el6.x86_ |  38 kB     00:00     
(10/27): libcom_err-devel-1.41.12-24.e |  33 kB     00:00     
(11/27): libkadm5-1.10.3-65.el6.x86_64 | 143 kB     00:00     
(12/27): libselinux-2.0.94-7.el6.x86_6 | 109 kB     00:00     
(13/27): libselinux-devel-2.0.94-7.el6 | 137 kB     00:00     
(14/27): libselinux-utils-2.0.94-7.el6 |  82 kB     00:00     
(15/27): libsepol-devel-2.0.41-4.el6.x |  64 kB     00:00     
(16/27): libss-1.41.12-24.el6.x86_64.r |  42 kB     00:00     
(17/27): libtool-2.2.6-15.5.el6.x86_64 | 564 kB     00:00     
(18/27): make-3.81-23.el6.x86_64.rpm   | 389 kB     00:00     
(19/27): openssl-1.0.1e-58.el6_10.x86_ | 1.5 MB     00:01     
(20/27): openssl-devel-1.0.1e-58.el6_1 | 1.2 MB     00:00     
(21/27): perl-5.10.1-144.el6.x86_64.rp |  10 MB     00:08     
(22/27): perl-Module-Pluggable-3.90-14 |  41 kB     00:00     
(23/27): perl-Pod-Escapes-1.04-144.el6 |  33 kB     00:00     
(24/27): perl-Pod-Simple-3.13-144.el6. | 213 kB     00:00     
(25/27): perl-libs-5.10.1-144.el6.x86_ | 579 kB     00:00     
(26/27): perl-version-0.77-144.el6.x86 |  52 kB     00:00     
(27/27): zlib-devel-1.2.3-29.el6.x86_6 |  44 kB     00:00     
--------------------------------------------------------------
Total                         1.1 MB/s |  19 MB     00:16     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libcom_err-1.41.12-24.el6.x86_64          1/37 
  Updating   : libselinux-2.0.94-7.el6.x86_64            2/37 
  Updating   : keyutils-libs-1.4-5.el6.x86_64            3/37 
  Updating   : krb5-libs-1.10.3-65.el6.x86_64            4/37 
  Installing : libkadm5-1.10.3-65.el6.x86_64             5/37 
  Installing : keyutils-libs-devel-1.4-5.el6.x86_64      6/37 
  Updating   : e2fsprogs-libs-1.41.12-24.el6.x86_64      7/37 
  Installing : libcom_err-devel-1.41.12-24.el6.x86_64    8/37 
  Updating   : libss-1.41.12-24.el6.x86_64               9/37 
  Installing : 1:perl-Pod-Escapes-1.04-144.el6.x86_64   10/37 
  Installing : 4:perl-libs-5.10.1-144.el6.x86_64        11/37 
  Installing : 1:perl-Pod-Simple-3.13-144.el6.x86_64    12/37 
  Installing : 1:perl-Module-Pluggable-3.90-144.el6.x   13/37 
  Installing : 3:perl-version-0.77-144.el6.x86_64       14/37 
  Installing : 4:perl-5.10.1-144.el6.x86_64             15/37 
  Installing : autoconf-2.63-5.1.el6.noarch             16/37 
  Installing : automake-1.11.1-4.el6.noarch             17/37 
  Installing : libsepol-devel-2.0.41-4.el6.x86_64       18/37 
  Installing : libselinux-devel-2.0.94-7.el6.x86_64     19/37 
  Installing : krb5-devel-1.10.3-65.el6.x86_64          20/37 
  Updating   : 1:make-3.81-23.el6.x86_64                21/37 
  Updating   : openssl-1.0.1e-58.el6_10.x86_64          22/37 
  Installing : zlib-devel-1.2.3-29.el6.x86_64           23/37 
  Installing : openssl-devel-1.0.1e-58.el6_10.x86_64    24/37 
  Installing : libtool-2.2.6-15.5.el6.x86_64            25/37 
  Updating   : e2fsprogs-1.41.12-24.el6.x86_64          26/37 
  Updating   : libselinux-utils-2.0.94-7.el6.x86_64     27/37 
  Cleanup    : e2fsprogs-1.41.12-18.el6.x86_64          28/37 
  Cleanup    : openssl-1.0.1e-15.el6.x86_64             29/37 
  Cleanup    : krb5-libs-1.10.3-10.el6_4.6.x86_64       30/37 
  Cleanup    : e2fsprogs-libs-1.41.12-18.el6.x86_64     31/37 
  Cleanup    : libss-1.41.12-18.el6.x86_64              32/37 
  Cleanup    : libselinux-utils-2.0.94-5.3.el6_4.1.x8   33/37 
  Cleanup    : libselinux-2.0.94-5.3.el6_4.1.x86_64     34/37 
  Cleanup    : libcom_err-1.41.12-18.el6.x86_64         35/37 
  Cleanup    : keyutils-libs-1.4-4.el6.x86_64           36/37 
  Cleanup    : 1:make-3.81-20.el6.x86_64                37/37 
  Verifying  : 3:perl-version-0.77-144.el6.x86_64        1/37 
  Verifying  : 4:perl-5.10.1-144.el6.x86_64              2/37 
  Verifying  : krb5-devel-1.10.3-65.el6.x86_64           3/37 
  Verifying  : krb5-libs-1.10.3-65.el6.x86_64            4/37 
  Verifying  : e2fsprogs-libs-1.41.12-24.el6.x86_64      5/37 
  Verifying  : automake-1.11.1-4.el6.noarch              6/37 
  Verifying  : libcom_err-devel-1.41.12-24.el6.x86_64    7/37 
  Verifying  : keyutils-libs-devel-1.4-5.el6.x86_64      8/37 
  Verifying  : 4:perl-libs-5.10.1-144.el6.x86_64         9/37 
  Verifying  : libss-1.41.12-24.el6.x86_64              10/37 
  Verifying  : zlib-devel-1.2.3-29.el6.x86_64           11/37 
  Verifying  : 1:perl-Pod-Simple-3.13-144.el6.x86_64    12/37 
  Verifying  : 1:perl-Pod-Escapes-1.04-144.el6.x86_64   13/37 
  Verifying  : libselinux-devel-2.0.94-7.el6.x86_64     14/37 
  Verifying  : keyutils-libs-1.4-5.el6.x86_64           15/37 
  Verifying  : 1:make-3.81-23.el6.x86_64                16/37 
  Verifying  : openssl-1.0.1e-58.el6_10.x86_64          17/37 
  Verifying  : autoconf-2.63-5.1.el6.noarch             18/37 
  Verifying  : 1:perl-Module-Pluggable-3.90-144.el6.x   19/37 
  Verifying  : libcom_err-1.41.12-24.el6.x86_64         20/37 
  Verifying  : libsepol-devel-2.0.41-4.el6.x86_64       21/37 
  Verifying  : openssl-devel-1.0.1e-58.el6_10.x86_64    22/37 
  Verifying  : libselinux-utils-2.0.94-7.el6.x86_64     23/37 
  Verifying  : libkadm5-1.10.3-65.el6.x86_64            24/37 
  Verifying  : libselinux-2.0.94-7.el6.x86_64           25/37 
  Verifying  : libtool-2.2.6-15.5.el6.x86_64            26/37 
  Verifying  : e2fsprogs-1.41.12-24.el6.x86_64          27/37 
  Verifying  : e2fsprogs-1.41.12-18.el6.x86_64          28/37 
  Verifying  : libselinux-2.0.94-5.3.el6_4.1.x86_64     29/37 
  Verifying  : openssl-1.0.1e-15.el6.x86_64             30/37 
  Verifying  : libselinux-utils-2.0.94-5.3.el6_4.1.x8   31/37 
  Verifying  : libcom_err-1.41.12-18.el6.x86_64         32/37 
  Verifying  : e2fsprogs-libs-1.41.12-18.el6.x86_64     33/37 
  Verifying  : 1:make-3.81-20.el6.x86_64                34/37 
  Verifying  : krb5-libs-1.10.3-10.el6_4.6.x86_64       35/37 
  Verifying  : libss-1.41.12-18.el6.x86_64              36/37 
  Verifying  : keyutils-libs-1.4-4.el6.x86_64           37/37 

Installed:
  libtool.x86_64 0:2.2.6-15.5.el6                             
  openssl-devel.x86_64 0:1.0.1e-58.el6_10                     
  zlib-devel.x86_64 0:1.2.3-29.el6                            

Dependency Installed:
  autoconf.noarch 0:2.63-5.1.el6                              
  automake.noarch 0:1.11.1-4.el6                              
  keyutils-libs-devel.x86_64 0:1.4-5.el6                      
  krb5-devel.x86_64 0:1.10.3-65.el6                           
  libcom_err-devel.x86_64 0:1.41.12-24.el6                    
  libkadm5.x86_64 0:1.10.3-65.el6                             
  libselinux-devel.x86_64 0:2.0.94-7.el6                      
  libsepol-devel.x86_64 0:2.0.41-4.el6                        
  perl.x86_64 4:5.10.1-144.el6                                
  perl-Module-Pluggable.x86_64 1:3.90-144.el6                 
  perl-Pod-Escapes.x86_64 1:1.04-144.el6                      
  perl-Pod-Simple.x86_64 1:3.13-144.el6                       
  perl-libs.x86_64 4:5.10.1-144.el6                           
  perl-version.x86_64 3:0.77-144.el6                          

Updated:
  make.x86_64 1:3.81-23.el6 openssl.x86_64 0:1.0.1e-58.el6_10

Dependency Updated:
  e2fsprogs.x86_64 0:1.41.12-24.el6                           
  e2fsprogs-libs.x86_64 0:1.41.12-24.el6                      
  keyutils-libs.x86_64 0:1.4-5.el6                            
  krb5-libs.x86_64 0:1.10.3-65.el6                            
  libcom_err.x86_64 0:1.41.12-24.el6                          
  libselinux.x86_64 0:2.0.94-7.el6                            
  libselinux-utils.x86_64 0:2.0.94-7.el6                      
  libss.x86_64 0:1.41.12-24.el6                               

Complete!

二、首先要安装 PCRE
PCRE 作用是让 Nginx 支持 Rewrite 功能。

1、下载 PCRE 安装包,下载地址:

http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

[root@bogon src]# cd /usr/local/src/
[root@bogon src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

如果wget没有安装的话,需要先安装wget,yum -y install wget

[root@linux1 src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
-bash: wget: command not found
[root@linux1 src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
-bash: wget: command not found
[root@linux1 src]# yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.12-10.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package    Arch         Version             Repository  Size
==============================================================
Installing:
 wget       x86_64       1.12-10.el6         base       484 k

Transaction Summary
==============================================================
Install       1 Package(s)

Total download size: 484 k
Installed size: 1.8 M
Downloading Packages:
wget-1.12-10.el6.x86_64.rpm            | 484 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : wget-1.12-10.el6.x86_64                    1/1 
  Verifying  : wget-1.12-10.el6.x86_64                    1/1 

Installed:
  wget.x86_64 0:1.12-10.el6                                   

Complete!

2、解压安装包:

[root@bogon src]# tar zxvf pcre-8.35.tar.gz
3、进入安装包目录

[root@bogon src]# cd pcre-8.35
4、编译安装

[root@bogon pcre-8.35]# ./configure
[root@bogon pcre-8.35]# make && make install
5、查看pcre版本

[root@bogon pcre-8.35]# pcre-config --version

[root@linux1 pcre-8.35]# pcre-config --version
8.35
[root@linux1 pcre-8.35]# 

安装 Nginx
1、下载 Nginx,下载地址:http://nginx.org/download/nginx-1.6.2.tar.gz

[root@bogon src]# cd /usr/local/src/
[root@bogon src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz

2、解压安装包

[root@bogon src]# tar zxvf nginx-1.6.2.tar.gz
3、进入安装包目录

[root@bogon src]# cd nginx-1.6.2
4、编译安装

[root@bogon nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
[root@bogon nginx-1.6.2]# make
[root@bogon nginx-1.6.2]# make install
5、查看nginx版本

[root@bogon nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v
到此,nginx安装完成。

[root@linux1 nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v
nginx version: nginx/1.6.2
[root@linux1 nginx-1.6.2]# 

Nginx 配置
创建 Nginx 运行使用的用户 www:

[root@bogon conf]# /usr/sbin/groupadd www
[root@bogon conf]# /usr/sbin/useradd -g www www
配置nginx.conf ,将/usr/local/webserver/nginx/conf/nginx.conf替换为以下内容

[root@bogon conf]# cat /usr/local/webserver/nginx/conf/nginx.conf


```c
user www www;
worker_processes 2; #设置值和CPU核心数一致
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
  use epoll;
  worker_connections 65535;
}
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';
  
#charset gb2312;
     
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 8m;
     
  sendfile on;
  tcp_nopush on;
  keepalive_timeout 60;
  tcp_nodelay on;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;
  gzip on; 
  gzip_min_length 1k;
  gzip_buffers 4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types text/plain application/x-javascript text/css application/xml;
  gzip_vary on;
 
  #limit_zone crawler $binary_remote_addr 10m;
 #下面是server虚拟主机的配置
 server
  {
    listen 80;#监听端口
    server_name localhost;#域名
    index index.html index.htm index.php;
    root /usr/local/webserver/nginx/html;#站点目录
      location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass unix:/tmp/php-cgi.sock;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
    {
      expires 30d;
  # access_log off;
    }
    location ~ .*\.(js|css)?$
    {
      expires 15d;
   # access_log off;
    }
    access_log off;
  }

}

检查配置文件nginx.conf的正确性命令:

[root@bogon conf]# /usr/local/webserver/nginx/sbin/nginx -t

```c
[root@linux1 nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful

启动 Nginx
Nginx 启动命令如下:

[root@bogon conf]# /usr/local/webserver/nginx/sbin/nginx

[root@linux1 nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx
[root@linux1 nginx-1.6.2]# ps -ef|grep nginx
root      10663      1  0 10:05 ?        00:00:00 nginx: master process /usr/local/webserver/nginx/sbin/nginx
www       10664  10663  0 10:05 ?        00:00:00 nginx: worker process                
root      10666   1160  0 10:05 pts/0    00:00:00 grep nginx

访问站点
从浏览器访问我们配置的站点ip:

Nginx 其他命令
以下包含了 Nginx 常用的几个命令:

/usr/local/webserver/nginx/sbin/nginx -s reload # 重新载入配置文件
/usr/local/webserver/nginx/sbin/nginx -s reopen # 重启 Nginx
/usr/local/webserver/nginx/sbin/nginx -s stop # 停止 Nginx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Nginx(linux安装) 的相关文章

随机推荐

  • Java线程test

    1 银行有一个账户有两个储户存分别向同一个账户存3000 元 xff0c 每次存1000 xff0c 存3次 每次存完打印账户余额 问题 xff1a 该程序是否有安全问题 xff0c 如果有 xff0c 如何解决 xff1f 提示 1 xf
  • java daytest

    1 为什么要有类的继承性 类的继承性可以减少代码冗余度 xff0c 提高代码复用性 xff0c 提高代码操作效率 2 继承的格式 xff08 语法 xff09 子类 extends 父类 3 子类继承父类后有哪些不同 子类范围大于父类 xf
  • 【rustdesk】rust入门及 windows 客户端尝试编译

    rustup 微软建议用vs code开发 官方faq 构建rustdesk 大神构建的经验 下载了64位的版本 vs code 插件 rust analyer 介绍 Better TOML 用于更好的展示 toml文件 Error Len
  • Java中创建线程主要有三种方式

    创建线程的方式及实现 Java中创建线程主要有三种方式 xff1a 一 继承Thread类创建线程类 xff08 1 xff09 定义Thread类的子类 xff0c 并重写该类的run方法 xff0c 该run方法的方法体就代表了线程要完
  • javaTest

    一 xff1a 简答题 xff08 5分 xff09 什么是java序列化 xff0c 如何实现java序列化 xff1f 答 xff1a 序列化就是一种用来处理对象流的机制 xff0c 所谓对象流也就是将对象的内容进行流化 可以对流化后的
  • MySQL使用过程中可能出现的错误

    1 mysql下载地址下载地址 xff1a https dev mysql com downloads windows installer 8 0 html 2 更改加密方式 xff1a mysql span class token ope
  • DOM介绍BOM

    DOM介绍 D xff08 文档 xff09 可以理解为整个Web加载的网页文档 xff0c O xff08 对象 xff09 可以理解为类似window对象只来的东西 xff0c 可以调用属性和方法 xff0c 这里我们说的是docume
  • JavaScript基本概念

    本章节介绍了 JavaScript xff0c 并且讨论了它的一些基本概念 你应该已经掌握哪些知识 xff1f 节 我们假设你已经掌握了以下基础技能 xff1a 对互联网和万维网 xff08 WWW xff09 有基本的认识 熟悉超文本标记
  • HTML,CSS,以及基础javaScript

    1 HTML 是一种在 Web 上使用的通用标记语言 HTML 允许你格式化文本 xff0c 添加图片 xff0c 创建链接 输入表单 框架和表格等等 xff0c 并可将之存为文本文件 xff0c 浏览器即可读取和显示 1 1HTML 的关
  • jQuery

    jQuery是一个JavaScript函数库 jQuery是一个轻量级的 34 写的少 xff0c 做的多 34 的JavaScript库 类似于一种框架 jQuery库包含以下功能 xff1a HTML 元素选取HTML 元素操作CSS
  • 欢迎使用Maven编辑器

    Maven安装与配置 一 需要准备的东西 JDK Eclipse Maven程序包 二 下载与安装 前往https maven apache org download cgi下载最新版的Maven程序 xff1a 将文件解压到D Progr
  • No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

    运行maven时报错如下 INFO Scanning for projects INFO INFO lt cn test MavenTest gt INFO Building MavenTest 0 0 1 SNAPSHOT INFO ja
  • MySQL语法糖

    1 配置MySQL需要注意哪几个问题 用户名 xff0c 密码 xff0c 端口号 xff0c 2 如何使用root账号登录MySQL net start mysql57 mysql u root p 3 创建表 查看表 查看表定义 删除表
  • 【rustdesk】配置rsproxy.cn 以 cargo add num

    配置 rsproxy cn num库里有复数 cargo add num 网络错误 PS D span class token punctuation span XTRANS span class token punctuation spa
  • collection集合层次结构

  • Eclipse启动web项目非常缓慢,崩溃

    xml文件版本问题 xff0c 需要联网效验 xff0c 重写web xml xff0c 获取新的xml覆盖原来的就行
  • SQL语句库联系

    Studentdent S Sname Sage Ssex 学生表 Course C Cname T 课程表 SC S C score 成绩表 Teacher T Tname 教师表 1 查询 001 课程比 002 课程成绩高的所有学生的
  • Linux安装redis全步骤

    第一步 xff1a 下载安装包 访问https redis io download 到官网进行下载 第二步 xff1a 安装 1 通过远程管理工具 xff0c 将压缩包拷贝到Linux服务器中 xff0c 执行解压操作 2 进入解压文件目录
  • CMD连接数据库Orcal连接数据库进行操作

    Microsoft Windows 版本 6 1 7601 版权所有 c 2009 Microsoft Corporation 保留所有权利 C Users Administrator gt sqlplus sys root 64 loca
  • Nginx(linux安装)

    Nginx engine x 是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器 xff0c 也是一个 IMAP POP3 SMTP 代理服务器 在高连接并发的情况下 xff0c Nginx是Apa