Linux系统Nginx安装

安装步奏:
1.安装gcc
执行指令:yum install gcc-c++

[root@hadoop03 gcc_package]# yum install gcc-c++
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-23.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.x86_64
--> Processing Dependency: libstdc++ = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.x86_64
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-16.el6 will be updated
---> Package gcc.x86_64 0:4.4.7-23.el6 will be an update
--> Processing Dependency: libgomp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
---> Package libstdc++.x86_64 0:4.4.7-16.el6 will be updated
---> Package libstdc++.x86_64 0:4.4.7-23.el6 will be an update
---> Package libstdc++-devel.x86_64 0:4.4.7-23.el6 will be installed
--> Running transaction check
---> Package cpp.x86_64 0:4.4.7-16.el6 will be updated
---> Package cpp.x86_64 0:4.4.7-23.el6 will be an update
---> Package libgcc.x86_64 0:4.4.7-16.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-23.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-16.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-23.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================
 Package                           Arch                     Version                           Repository              Size
===========================================================================================================================
Installing:
 gcc-c++                           x86_64                   4.4.7-23.el6                      base                   4.7 M
Installing for dependencies:
 libstdc++-devel                   x86_64                   4.4.7-23.el6                      base                   1.6 M
Updating for dependencies:
 cpp                               x86_64                   4.4.7-23.el6                      base                   3.7 M
 gcc                               x86_64                   4.4.7-23.el6                      base                    10 M
 libgcc                            x86_64                   4.4.7-23.el6                      base                   104 k
 libgomp                           x86_64                   4.4.7-23.el6                      base                   135 k
 libstdc++                         x86_64                   4.4.7-23.el6                      base                   296 k

Transaction Summary
===========================================================================================================================
Install       2 Package(s)
Upgrade       5 Package(s)

Total download size: 21 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): cpp-4.4.7-23.el6.x86_64.rpm                                                                  | 3.7 MB     00:00     
(2/7): gcc-4.4.7-23.el6.x86_64.rpm                                                                  |  10 MB     00:01     
(3/7): gcc-c++-4.4.7-23.el6.x86_64.rpm                                                              | 4.7 MB     00:00     
(4/7): libgcc-4.4.7-23.el6.x86_64.rpm                                                               | 104 kB     00:00     
(5/7): libgomp-4.4.7-23.el6.x86_64.rpm                                                              | 135 kB     00:00     
(6/7): libstdc++-4.4.7-23.el6.x86_64.rpm                                                            | 296 kB     00:00     
(7/7): libstdc++-devel-4.4.7-23.el6.x86_64.rpm                                                      | 1.6 MB     00:00     
---------------------------------------------------------------------------------------------------------------------------
Total                                                                                      6.5 MB/s |  21 MB     00:03     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : libgcc-4.4.7-23.el6.x86_64                                                                             1/12 
  Updating   : libstdc++-4.4.7-23.el6.x86_64                                                                          2/12 
  Installing : libstdc++-devel-4.4.7-23.el6.x86_64                                                                    3/12 
  Updating   : cpp-4.4.7-23.el6.x86_64                                                                                4/12 
  Updating   : libgomp-4.4.7-23.el6.x86_64                                                                            5/12 
  Updating   : gcc-4.4.7-23.el6.x86_64                                                                                6/12 
  Installing : gcc-c++-4.4.7-23.el6.x86_64                                                                            7/12 
  Cleanup    : gcc-4.4.7-16.el6.x86_64                                                                                8/12 
  Cleanup    : libstdc++-4.4.7-16.el6.x86_64                                                                          9/12 
  Cleanup    : libgcc-4.4.7-16.el6.x86_64                                                                            10/12 
  Cleanup    : cpp-4.4.7-16.el6.x86_64                                                                               11/12 
  Cleanup    : libgomp-4.4.7-16.el6.x86_64                                                                           12/12 
  Verifying  : gcc-c++-4.4.7-23.el6.x86_64                                                                            1/12 
  Verifying  : gcc-4.4.7-23.el6.x86_64                                                                                2/12 
  Verifying  : libgomp-4.4.7-23.el6.x86_64                                                                            3/12 
  Verifying  : libgcc-4.4.7-23.el6.x86_64                                                                             4/12 
  Verifying  : cpp-4.4.7-23.el6.x86_64                                                                                5/12 
  Verifying  : libstdc++-devel-4.4.7-23.el6.x86_64                                                                    6/12 
  Verifying  : libstdc++-4.4.7-23.el6.x86_64                                                                          7/12 
  Verifying  : libgomp-4.4.7-16.el6.x86_64                                                                            8/12 
  Verifying  : gcc-4.4.7-16.el6.x86_64                                                                                9/12 
  Verifying  : libstdc++-4.4.7-16.el6.x86_64                                                                         10/12 
  Verifying  : cpp-4.4.7-16.el6.x86_64                                                                               11/12 
  Verifying  : libgcc-4.4.7-16.el6.x86_64                                                                            12/12 

Installed:
  gcc-c++.x86_64 0:4.4.7-23.el6                                                                                            

Dependency Installed:
  libstdc++-devel.x86_64 0:4.4.7-23.el6                                                                                    

Dependency Updated:
  cpp.x86_64 0:4.4.7-23.el6        gcc.x86_64 0:4.4.7-23.el6  libgcc.x86_64 0:4.4.7-23.el6  libgomp.x86_64 0:4.4.7-23.el6 
  libstdc++.x86_64 0:4.4.7-23.el6 

Complete!

2.安装pcre
方式1:

  • yum在线安装:yum -y install gcc pcre-devel openssl openssl-devel

方式2:

  • 离线下载:https://sourceforge.net/projects/pcre/files/pcre/
  • 上传到Linux
  • 解压:tar -zxvf pcre-8.39.gz
  • 进入解压后的目录,执行:./configure
  • 编译:make
  • 安装:make install
[root@hadoop03 software]# cd pcre-8.39
[root@hadoop03 pcre-8.39]# ls
132html            libpcre.pc.in         pcre16_string_utils.c  pcre32_version.c        pcreposix.h
aclocal.m4         libpcreposix.pc.in    pcre16_study.c         pcre32_xclass.c         pcre_printint.c
ar-lib             LICENCE               pcre16_tables.c        pcre_byte_order.c       pcre_refcount.c
AUTHORS            ltmain.sh             pcre16_ucd.c           pcre_chartables.c.dist  pcre_scanner.cc
ChangeLog          m4                    pcre16_utf16_utils.c   pcre_compile.c          pcre_scanner.h
CheckMan           Makefile.am           pcre16_valid_utf16.c   pcre_config.c           pcre_scanner_unittest.cc
CleanTxt           Makefile.in           pcre16_version.c       pcre-config.in          pcre_stringpiece.cc
cmake              makevp.bat            pcre16_xclass.c        pcrecpparg.h.in         pcre_stringpiece.h.in
CMakeLists.txt     makevp_c.txt          pcre32_byte_order.c    pcrecpp.cc              pcre_stringpiece_unittest.cc
compile            makevp_l.txt          pcre32_chartables.c    pcrecpp.h               pcre_string_utils.c
config-cmake.h.in  missing               pcre32_compile.c       pcrecpp_internal.h      pcre_study.c
config.guess       NEWS                  pcre32_config.c        pcrecpp_unittest.cc     pcre_tables.c
config.h.generic   NON-AUTOTOOLS-BUILD   pcre32_dfa_exec.c      pcredemo.c              pcretest.c
config.h.in        NON-UNIX-USE          pcre32_exec.c          pcre_dfa_exec.c         pcre_ucd.c
config.log         pcre16_byte_order.c   pcre32_fullinfo.c      pcre_exec.c             pcre_valid_utf8.c
config.sub         pcre16_chartables.c   pcre32_get.c           pcre_fullinfo.c         pcre_version.c
configure          pcre16_compile.c      pcre32_globals.c       pcre_get.c              pcre_xclass.c
configure.ac       pcre16_config.c       pcre32_jit_compile.c   pcregexp.pas            perltest.pl
COPYING            pcre16_dfa_exec.c     pcre32_maketables.c    pcre_globals.c          PrepareRelease
depcomp            pcre16_exec.c         pcre32_newline.c       pcregrep.c              README
Detrail            pcre16_fullinfo.c     pcre32_ord2utf32.c     pcre.h.generic          RunGrepTest
dftables.c         pcre16_get.c          pcre32_printint.c      pcre.h.in               RunTest
doc                pcre16_globals.c      pcre32_refcount.c      pcre_internal.h         RunTest.bat
HACKING            pcre16_jit_compile.c  pcre32_string_utils.c  pcre_jit_compile.c      sljit
INSTALL            pcre16_maketables.c   pcre32_study.c         pcre_jit_test.c         testdata
install-sh         pcre16_newline.c      pcre32_tables.c        pcre_maketables.c       test-driver
libpcre16.pc.in    pcre16_ord2utf16.c    pcre32_ucd.c           pcre_newline.c          ucp.h
libpcre32.pc.in    pcre16_printint.c     pcre32_utf32_utils.c   pcre_ord2utf8.c
libpcrecpp.pc.in   pcre16_refcount.c     pcre32_valid_utf32.c   pcreposix.c
[root@hadoop03 pcre-8.39]# ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for int64_t... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1966080
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether ln -s works... yes
checking whether the -Werror option is usable... yes
checking for simple visibility declarations... yes
checking for ANSI C header files... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking windows.h usability... no
checking windows.h presence... no
checking for windows.h... no
checking for alias support in the linker... no
checking for alias support in the linker... no
checking string usability... yes
checking string presence... yes
checking for string... yes
checking bits/type_traits.h usability... no
checking bits/type_traits.h presence... no
checking for bits/type_traits.h... no
checking type_traits.h usability... no
checking type_traits.h presence... no
checking for type_traits.h... no
checking for strtoq... yes
checking for long long... yes
checking for unsigned long long... yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for bcopy... yes
checking for memmove... yes
checking for strerror... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for gzopen in -lz... yes
checking bzlib.h usability... no
checking bzlib.h presence... no
checking for bzlib.h... no
checking for libbz2... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libpcre.pc
config.status: creating libpcre16.pc
config.status: creating libpcre32.pc
config.status: creating libpcreposix.pc
config.status: creating libpcrecpp.pc
config.status: creating pcre-config
config.status: creating pcre.h
config.status: creating pcre_stringpiece.h
config.status: creating pcrecpparg.h
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing script-chmod commands
config.status: executing delete-old-chartables commands

pcre-8.39 configuration summary:

    Install prefix .................. : /usr/local
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ : 
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... : 
    Extra libraries ................. : 

    Build 8 bit pcre library ........ : yes
    Build 16 bit pcre library ....... : no
    Build 32 bit pcre library ....... : no
    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8/16/32 support ...... : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    EBCDIC code for NL .............. : n/a
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Nested parentheses limit ........ : 250
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no

[root@hadoop03 pcre-8.39]# make
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
make  all-am
make[1]: Entering directory `/home/01/software/pcre-8.39'
  CC       libpcre_la-pcre_byte_order.lo
  CC       libpcre_la-pcre_compile.lo
  CC       libpcre_la-pcre_config.lo
  CC       libpcre_la-pcre_dfa_exec.lo
  CC       libpcre_la-pcre_exec.lo
  CC       libpcre_la-pcre_fullinfo.lo
  CC       libpcre_la-pcre_get.lo
  CC       libpcre_la-pcre_globals.lo
  CC       libpcre_la-pcre_jit_compile.lo
  CC       libpcre_la-pcre_maketables.lo
  CC       libpcre_la-pcre_newline.lo
  CC       libpcre_la-pcre_ord2utf8.lo
  CC       libpcre_la-pcre_refcount.lo
  CC       libpcre_la-pcre_string_utils.lo
  CC       libpcre_la-pcre_study.lo
  CC       libpcre_la-pcre_tables.lo
  CC       libpcre_la-pcre_ucd.lo
  CC       libpcre_la-pcre_valid_utf8.lo
  CC       libpcre_la-pcre_version.lo
  CC       libpcre_la-pcre_xclass.lo
  CC       libpcre_la-pcre_chartables.lo
  CCLD     libpcre.la
  CC       libpcreposix_la-pcreposix.lo
  CCLD     libpcreposix.la
  CXX      libpcrecpp_la-pcrecpp.lo
  CXX      libpcrecpp_la-pcre_scanner.lo
  CXX      libpcrecpp_la-pcre_stringpiece.lo
  CXXLD    libpcrecpp.la
  CC       pcretest-pcretest.o
  CC       pcretest-pcre_printint.o
  CCLD     pcretest
  CC       pcregrep-pcregrep.o
  CCLD     pcregrep
  CXX      pcrecpp_unittest-pcrecpp_unittest.o
  CXXLD    pcrecpp_unittest
  CXX      pcre_scanner_unittest-pcre_scanner_unittest.o
  CXXLD    pcre_scanner_unittest
  CXX      pcre_stringpiece_unittest-pcre_stringpiece_unittest.o
  CXXLD    pcre_stringpiece_unittest
make[1]: Leaving directory `/home/01/software/pcre-8.39'
[root@hadoop03 pcre-8.39]# make install
make  install-am
make[1]: Entering directory `/home/01/software/pcre-8.39'
make[2]: Entering directory `/home/01/software/pcre-8.39'
 /bin/mkdir -p '/usr/local/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libpcre.la libpcreposix.la libpcrecpp.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libpcre.so.1.2.7 /usr/local/lib/libpcre.so.1.2.7
libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.1.2.7 libpcre.so.1 || { rm -f libpcre.so.1 && ln -s libpcre.so.1.2.7 libpcre.so.1; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.1.2.7 libpcre.so || { rm -f libpcre.so && ln -s libpcre.so.1.2.7 libpcre.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcre.lai /usr/local/lib/libpcre.la
libtool: warning: relinking 'libpcreposix.la'
libtool: install: (cd /home/01/software/pcre-8.39; /bin/sh "/home/01/software/pcre-8.39/libtool"  --silent --tag CC --mode=relink gcc -fvisibility=hidden -g -O2 -version-info 0:4:0 -o libpcreposix.la -rpath /usr/local/lib libpcreposix_la-pcreposix.lo libpcre.la )
libtool: install: /usr/bin/install -c .libs/libpcreposix.so.0.0.4T /usr/local/lib/libpcreposix.so.0.0.4
libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.4 libpcreposix.so.0 || { rm -f libpcreposix.so.0 && ln -s libpcreposix.so.0.0.4 libpcreposix.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.4 libpcreposix.so || { rm -f libpcreposix.so && ln -s libpcreposix.so.0.0.4 libpcreposix.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcreposix.lai /usr/local/lib/libpcreposix.la
libtool: warning: relinking 'libpcrecpp.la'
libtool: install: (cd /home/01/software/pcre-8.39; /bin/sh "/home/01/software/pcre-8.39/libtool"  --silent --tag CXX --mode=relink g++ -fvisibility=hidden -fvisibility-inlines-hidden -O2 -version-info 0:1:0 -o libpcrecpp.la -rpath /usr/local/lib libpcrecpp_la-pcrecpp.lo libpcrecpp_la-pcre_scanner.lo libpcrecpp_la-pcre_stringpiece.lo libpcre.la )
libtool: install: /usr/bin/install -c .libs/libpcrecpp.so.0.0.1T /usr/local/lib/libpcrecpp.so.0.0.1
libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.1 libpcrecpp.so.0 || { rm -f libpcrecpp.so.0 && ln -s libpcrecpp.so.0.0.1 libpcrecpp.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.1 libpcrecpp.so || { rm -f libpcrecpp.so && ln -s libpcrecpp.so.0.0.1 libpcrecpp.so; }; })
libtool: install: /usr/bin/install -c .libs/libpcrecpp.lai /usr/local/lib/libpcrecpp.la
libtool: install: /usr/bin/install -c .libs/libpcre.a /usr/local/lib/libpcre.a
libtool: install: chmod 644 /usr/local/lib/libpcre.a
libtool: install: ranlib /usr/local/lib/libpcre.a
libtool: install: /usr/bin/install -c .libs/libpcreposix.a /usr/local/lib/libpcreposix.a
libtool: install: chmod 644 /usr/local/lib/libpcreposix.a
libtool: install: ranlib /usr/local/lib/libpcreposix.a
libtool: install: /usr/bin/install -c .libs/libpcrecpp.a /usr/local/lib/libpcrecpp.a
libtool: install: chmod 644 /usr/local/lib/libpcrecpp.a
libtool: install: ranlib /usr/local/lib/libpcrecpp.a
libtool: finish: PATH="/home/01/software/jdk1.7.0_80/bin:/home/01/software/hadoop-2.7.1/bin:/home/01/software/hadoop-2.7.1/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/bin'
  /bin/sh ./libtool   --mode=install /usr/bin/install -c pcretest pcregrep '/usr/local/bin'
libtool: install: /usr/bin/install -c .libs/pcretest /usr/local/bin/pcretest
libtool: install: /usr/bin/install -c .libs/pcregrep /usr/local/bin/pcregrep
 /bin/mkdir -p '/usr/local/bin'
 /usr/bin/install -c pcre-config '/usr/local/bin'
 /bin/mkdir -p '/usr/local/share/doc/pcre'
 /usr/bin/install -c -m 644 doc/pcre.txt doc/pcre-config.txt doc/pcregrep.txt doc/pcretest.txt AUTHORS COPYING ChangeLog LICENCE NEWS README '/usr/local/share/doc/pcre'
 /bin/mkdir -p '/usr/local/share/doc/pcre/html'
 /usr/bin/install -c -m 644 doc/html/NON-AUTOTOOLS-BUILD.txt doc/html/README.txt doc/html/index.html doc/html/pcre-config.html doc/html/pcre.html doc/html/pcre16.html doc/html/pcre32.html doc/html/pcre_assign_jit_stack.html doc/html/pcre_compile.html doc/html/pcre_compile2.html doc/html/pcre_config.html doc/html/pcre_copy_named_substring.html doc/html/pcre_copy_substring.html doc/html/pcre_dfa_exec.html doc/html/pcre_exec.html doc/html/pcre_free_study.html doc/html/pcre_free_substring.html doc/html/pcre_free_substring_list.html doc/html/pcre_fullinfo.html doc/html/pcre_get_named_substring.html doc/html/pcre_get_stringnumber.html doc/html/pcre_get_stringtable_entries.html doc/html/pcre_get_substring.html doc/html/pcre_get_substring_list.html doc/html/pcre_jit_exec.html doc/html/pcre_jit_stack_alloc.html doc/html/pcre_jit_stack_free.html doc/html/pcre_maketables.html doc/html/pcre_pattern_to_host_byte_order.html doc/html/pcre_refcount.html doc/html/pcre_study.html doc/html/pcre_utf16_to_host_byte_order.html doc/html/pcre_utf32_to_host_byte_order.html doc/html/pcre_version.html doc/html/pcreapi.html doc/html/pcrebuild.html doc/html/pcrecallout.html doc/html/pcrecompat.html doc/html/pcredemo.html doc/html/pcregrep.html '/usr/local/share/doc/pcre/html'
 /usr/bin/install -c -m 644 doc/html/pcrejit.html doc/html/pcrelimits.html doc/html/pcrematching.html doc/html/pcrepartial.html doc/html/pcrepattern.html doc/html/pcreperform.html doc/html/pcreposix.html doc/html/pcreprecompile.html doc/html/pcresample.html doc/html/pcrestack.html doc/html/pcresyntax.html doc/html/pcretest.html doc/html/pcreunicode.html '/usr/local/share/doc/pcre/html'
 /bin/mkdir -p '/usr/local/share/doc/pcre/html'
 /usr/bin/install -c -m 644 doc/html/pcrecpp.html '/usr/local/share/doc/pcre/html'
 /bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 pcreposix.h pcrecpp.h pcre_scanner.h '/usr/local/include'
 /bin/mkdir -p '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 doc/pcre-config.1 doc/pcregrep.1 doc/pcretest.1 '/usr/local/share/man/man1'
 /bin/mkdir -p '/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 doc/pcre.3 doc/pcre16.3 doc/pcre32.3 doc/pcre_assign_jit_stack.3 doc/pcre_compile.3 doc/pcre_compile2.3 doc/pcre_config.3 doc/pcre_copy_named_substring.3 doc/pcre_copy_substring.3 doc/pcre_dfa_exec.3 doc/pcre_exec.3 doc/pcre_free_study.3 doc/pcre_free_substring.3 doc/pcre_free_substring_list.3 doc/pcre_fullinfo.3 doc/pcre_get_named_substring.3 doc/pcre_get_stringnumber.3 doc/pcre_get_stringtable_entries.3 doc/pcre_get_substring.3 doc/pcre_get_substring_list.3 doc/pcre_jit_exec.3 doc/pcre_jit_stack_alloc.3 doc/pcre_jit_stack_free.3 doc/pcre_maketables.3 doc/pcre_pattern_to_host_byte_order.3 doc/pcre_refcount.3 doc/pcre_study.3 doc/pcre_utf16_to_host_byte_order.3 doc/pcre_utf32_to_host_byte_order.3 doc/pcre_version.3 doc/pcreapi.3 doc/pcrebuild.3 doc/pcrecallout.3 doc/pcrecompat.3 doc/pcredemo.3 doc/pcrejit.3 doc/pcrelimits.3 doc/pcrematching.3 doc/pcrepartial.3 doc/pcrepattern.3 '/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 doc/pcreperform.3 doc/pcreposix.3 doc/pcreprecompile.3 doc/pcresample.3 doc/pcrestack.3 doc/pcresyntax.3 doc/pcreunicode.3 doc/pcrecpp.3 '/usr/local/share/man/man3'
 /bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 pcre.h pcrecpparg.h pcre_stringpiece.h '/usr/local/include'
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libpcre.pc libpcreposix.pc libpcrecpp.pc '/usr/local/lib/pkgconfig'
make  install-data-hook
make[3]: Entering directory `/home/01/software/pcre-8.39'
ln -sf pcre_assign_jit_stack.3		 /usr/local/share/man/man3/pcre16_assign_jit_stack.3
ln -sf pcre_compile.3			 /usr/local/share/man/man3/pcre16_compile.3
ln -sf pcre_compile2.3			 /usr/local/share/man/man3/pcre16_compile2.3
ln -sf pcre_config.3			 /usr/local/share/man/man3/pcre16_config.3
ln -sf pcre_copy_named_substring.3	 /usr/local/share/man/man3/pcre16_copy_named_substring.3
ln -sf pcre_copy_substring.3		 /usr/local/share/man/man3/pcre16_copy_substring.3
ln -sf pcre_dfa_exec.3			 /usr/local/share/man/man3/pcre16_dfa_exec.3
ln -sf pcre_exec.3			 /usr/local/share/man/man3/pcre16_exec.3
ln -sf pcre_free_study.3		 /usr/local/share/man/man3/pcre16_free_study.3
ln -sf pcre_free_substring.3		 /usr/local/share/man/man3/pcre16_free_substring.3
ln -sf pcre_free_substring_list.3	 /usr/local/share/man/man3/pcre16_free_substring_list.3
ln -sf pcre_fullinfo.3			 /usr/local/share/man/man3/pcre16_fullinfo.3
ln -sf pcre_get_named_substring.3	 /usr/local/share/man/man3/pcre16_get_named_substring.3
ln -sf pcre_get_stringnumber.3		 /usr/local/share/man/man3/pcre16_get_stringnumber.3
ln -sf pcre_get_stringtable_entries.3	 /usr/local/share/man/man3/pcre16_get_stringtable_entries.3
ln -sf pcre_get_substring.3		 /usr/local/share/man/man3/pcre16_get_substring.3
ln -sf pcre_get_substring_list.3	 /usr/local/share/man/man3/pcre16_get_substring_list.3
ln -sf pcre_jit_exec.3			 /usr/local/share/man/man3/pcre16_jit_exec.3
ln -sf pcre_jit_stack_alloc.3		 /usr/local/share/man/man3/pcre16_jit_stack_alloc.3
ln -sf pcre_jit_stack_free.3		 /usr/local/share/man/man3/pcre16_jit_stack_free.3
ln -sf pcre_maketables.3		 /usr/local/share/man/man3/pcre16_maketables.3
ln -sf pcre_pattern_to_host_byte_order.3 /usr/local/share/man/man3/pcre16_pattern_to_host_byte_order.3
ln -sf pcre_refcount.3			 /usr/local/share/man/man3/pcre16_refcount.3
ln -sf pcre_study.3			 /usr/local/share/man/man3/pcre16_study.3
ln -sf pcre_utf16_to_host_byte_order.3	 /usr/local/share/man/man3/pcre16_utf16_to_host_byte_order.3
ln -sf pcre_version.3			 /usr/local/share/man/man3/pcre16_version.3
ln -sf pcre_assign_jit_stack.3		 /usr/local/share/man/man3/pcre32_assign_jit_stack.3
ln -sf pcre_compile.3			 /usr/local/share/man/man3/pcre32_compile.3
ln -sf pcre_compile2.3			 /usr/local/share/man/man3/pcre32_compile2.3
ln -sf pcre_config.3			 /usr/local/share/man/man3/pcre32_config.3
ln -sf pcre_copy_named_substring.3	 /usr/local/share/man/man3/pcre32_copy_named_substring.3
ln -sf pcre_copy_substring.3		 /usr/local/share/man/man3/pcre32_copy_substring.3
ln -sf pcre_dfa_exec.3			 /usr/local/share/man/man3/pcre32_dfa_exec.3
ln -sf pcre_exec.3			 /usr/local/share/man/man3/pcre32_exec.3
ln -sf pcre_free_study.3		 /usr/local/share/man/man3/pcre32_free_study.3
ln -sf pcre_free_substring.3		 /usr/local/share/man/man3/pcre32_free_substring.3
ln -sf pcre_free_substring_list.3	 /usr/local/share/man/man3/pcre32_free_substring_list.3
ln -sf pcre_fullinfo.3			 /usr/local/share/man/man3/pcre32_fullinfo.3
ln -sf pcre_get_named_substring.3	 /usr/local/share/man/man3/pcre32_get_named_substring.3
ln -sf pcre_get_stringnumber.3		 /usr/local/share/man/man3/pcre32_get_stringnumber.3
ln -sf pcre_get_stringtable_entries.3	 /usr/local/share/man/man3/pcre32_get_stringtable_entries.3
ln -sf pcre_get_substring.3		 /usr/local/share/man/man3/pcre32_get_substring.3
ln -sf pcre_get_substring_list.3	 /usr/local/share/man/man3/pcre32_get_substring_list.3
ln -sf pcre_jit_exec.3			 /usr/local/share/man/man3/pcre32_jit_exec.3
ln -sf pcre_jit_stack_alloc.3		 /usr/local/share/man/man3/pcre32_jit_stack_alloc.3
ln -sf pcre_jit_stack_free.3		 /usr/local/share/man/man3/pcre32_jit_stack_free.3
ln -sf pcre_maketables.3		 /usr/local/share/man/man3/pcre32_maketables.3
ln -sf pcre_pattern_to_host_byte_order.3 /usr/local/share/man/man3/pcre32_pattern_to_host_byte_order.3
ln -sf pcre_refcount.3			 /usr/local/share/man/man3/pcre32_refcount.3
ln -sf pcre_study.3			 /usr/local/share/man/man3/pcre32_study.3
ln -sf pcre_utf32_to_host_byte_order.3	 /usr/local/share/man/man3/pcre32_utf32_to_host_byte_order.3
ln -sf pcre_version.3			 /usr/local/share/man/man3/pcre32_version.3
make[3]: Leaving directory `/home/01/software/pcre-8.39'
make[2]: Leaving directory `/home/01/software/pcre-8.39'
make[1]: Leaving directory `/home/01/software/pcre-8.39'

3.安装zlib-devel
执行下载命令:wget http://mirror.centos.org/centos/6/os/x86_64/Packages/zlib-devel-1.2.3-29.el6.x86_64.rpm
执行安装命令:rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm

4.安装Nginx
下载nginx安装包网址:http://nginx.org/download/
我这里安装nginx-1.9.9.tar.gz
上传到Linux
解压 :tar -zxvf nginx-1.9.9.tar.gz
解压后进入文件目录
编译安装:./configure --prefix=指定安装目录 --with-pcre=pcre安装位置
编译安装完成后执行:make install

[root@hadoop03 software]# cd nginx-1.9.9
[root@hadoop03 nginx-1.9.9]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@hadoop03 nginx-1.9.9]# ./configure --prefix=/home/01/software/nginx --with-pcre=/home/01/software/pcre-8.39
checking for OS
 + Linux 2.6.32-573.el6.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 
...
...
...
Configuration summary
  + using PCRE library: /home/01/software/pcre-8.39
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: "/home/01/software/nginx"
  nginx binary file: "/home/01/software/nginx/sbin/nginx"
  nginx configuration prefix: "/home/01/software/nginx/conf"
  nginx configuration file: "/home/01/software/nginx/conf/nginx.conf"
  nginx pid file: "/home/01/software/nginx/logs/nginx.pid"
  nginx error log file: "/home/01/software/nginx/logs/error.log"
  nginx http access log file: "/home/01/software/nginx/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"

[root@hadoop03 nginx-1.9.9]# make install
make -f objs/Makefile install
make[1]: Entering directory `/home/01/software/nginx-1.9.9'
cd /home/01/software/pcre-8.39 \
...

make[1]: Leaving directory `/home/01/software/nginx-1.9.9'
#指定的安装目录下多了个nginx文件夹
[root@hadoop03 software]# ls
apache-hive-1.2.0-bin          jdk-7u80-linux-x64.tar.gz                        nginx-1.9.9.tar.gz
apache-maven-3.6.1-bin.tar.gz  kafka_2.10                                       pcre-8.39
flume-1.6                      kafka_2.11                                       pcre-8.39.gz
gcc_package                    MySQL-client-5.6.29-1.linux_glibc2.5.x86_64.rpm  spark-2.0.1-bin-hadoop2.7
hadoop-2.7.1                   MySQL-server-5.6.29-1.linux_glibc2.5.x86_64.rpm  tomcat8.5
hbase-0.98.17-hadoop2          nc-1.84-22.el6.x86_64.rpm                        zlib-devel-1.2.3-29.el6.x86_64.rpm
jdk1.7.0_80                    nginx                                            zookeeper-3.4.7
jdk1.8                         nginx-1.9.9

5.Nginx配置
在nginx下配置conf/nginx.conf

#添加upstream backend{}
upstream backend {
	#ip_hash;
	server 123.56.71.150:8080;
	server 123.56.71.151:8080;
	server 123.56.71.152:8080;
}
#修改server{}
#当客服端访问此服务器的80端口时会调用反向代理将访问指向http://backend
#而http://backend的访问地址则是upstream backend{}里的众多服务器里的其中一个ip地址
#从而实现nginx反向代理负载均衡
server {  
	listen       80;  
	server_name  123.56.71.150;  

	location / {     
		proxy_connect_timeout   3;     
		proxy_send_timeout      30;     
		proxy_read_timeout      30;     
		proxy_pass http://backend;     
	}

}

Nginx配置负载均衡方式:

1、轮询
轮询即Round Robin,根据Nginx配置文件中的顺序,依次把客户端的Web请求分发到不同的后端服务器。
配置的例子如下:

http{ 
        upstream sampleapp { 
	        server 123.56.71.150:8080;
			server 123.56.71.151:8080;
			server 123.56.71.152:8080;
		} 
.... 
		server{ 
		        listen 80; 
		        ... 
		        location / { 
		                proxy_pass http://sampleapp; 
		        }  
		} 
}

上面只有1个DNS入口被插入到upstream节,即sampleapp,同样也在后面的proxy_pass节重新提到。

2、最少连接
Web请求会被转发到连接数最少的服务器上。
配置的例子如下:

http{ 
        upstream sampleapp { 
	        least_conn; 
	        server 123.56.71.150:8080;
			server 123.56.71.151:8080;
			server 123.56.71.152:8080;
        } 
        .... 
        server{ 
                listen 80; 
                ... 
                location / { 
                proxy_pass  http://sampleapp; 
                }
        }  
} 

上面的例子只是在upstream节添加了least_conn配置。其它的配置同轮询配置。

3、IP地址哈希
前述的两种负载均衡方案中,同一客户端连续的Web请求可能会被分发到不同的后端服务器进行处理,因此如果涉及到会话Session,那么会话会比较复杂。常见的是基于数据库的会话持久化。要克服上面的难题,可以使用基于IP地址哈希的负载均衡方案。这样的话,同一客户端连续的Web请求都会被分发到同一服务器进行处理。
配置的例子如下:

http{ 
        upstream sampleapp { 
       		   ip_hash; 
               server 123.56.71.150:8080;
		 	   server 123.56.71.151:8080;
			   server 123.56.71.152:8080;
        } 
        .... 
        server{ 
                listen 80; 
                ... 
                location / { 
                proxy_pass  http://sampleapp; 
                }
        }  
} 

上面的例子只是在upstream节添加了ip_hash配置。其它的配置同轮询配置。

4、基于权重的负载均衡
基于权重的负载均衡即Weighted Load Balancing,这种方式下,我们可以配置Nginx把请求更多地分发到高配置的后端服务器上,把相对较少的请求分发到低配服务器。
配置的例子如下:

http{ 
        upstream sampleapp { 
               server 123.56.71.150:8080 weight=2; ;
		 	   server 123.56.71.151:8080;
			   server 123.56.71.152:8080;
        } 
        .... 
        server{ 
                listen 80; 
                ... 
                location / { 
                proxy_pass  http://sampleapp; 
                }
        } 
} 

上面的例子在服务器地址和端口后weight=2的配置,这意味着,每接收到3个请求,前2个请求会被分发到第一个服务器,第3个请求会分发到第二个服务器,其它的配置同轮询配置。
还要说明一点,基于权重的负载均衡和基于IP地址哈希的负载均衡可以组合在一起使用。

6.启动和关闭nginx
进入sbin目录下执行启动命令:./nginx

[root@hadoop03 nginx]# cd sbin
[root@hadoop03 sbin]# ls
nginx
[root@hadoop03 sbin]# ./nginx
#查看nginx运行了没
[root@hadoop03 sbin]# ps -ef|grep nginx
root     108022      1  0 15:46 ?        00:00:00 nginx: master process ./nginx
nobody   108023 108022  0 15:46 ?        00:00:00 nginx: worker process
root     108025  87626  0 15:46 pts/0    00:00:00 grep nginx

nginx其他命令操作:
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

关闭nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx

其他的停止nginx 方式:

ps -ef | grep nginx

[root@hadoop03 sbin]# ps -ef|grep nginx
#用户    进程ID     
root     108022      1  0 15:46 ?        00:00:00 nginx: master process ./nginx
nobody   108023 108022  0 15:46 ?        00:00:00 nginx: worker process
root     108025  87626  0 15:46 pts/0    00:00:00 grep nginx

kill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx :强制停止Nginx

7.检测nginx能否实现反向代理
直接访问:http://配置nginx的服务器主机名(默认端口:80可以不写)
在这里插入图片描述
上图可以验证nginx可以实现反向代理(配置nginx的服务器没有安装tomcat,这时候我们通过80端口访问这台服务器,直接跳转到tomcat页面说明nginx起到一个反向代理,将请求转向给其他服务器,我们可以nginx反向代理实现多台服务器之间的负载均衡效果)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值