Redhat7.4下安裝nginx-1.14

 

1)yum直接安裝依賴包
yum install pcre-devel pcre gcc gcc-c++ zlib-devel zlib openssl* -y   (安裝依賴)
tar -zxvf nginx-1.14.1.tar.gz 
cd /software/nginx-1.14.1
adduser nginx   (添加系統用戶)
./configure --prefix=/software/nginx --user=nginx --group=nginx --with-stream --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module   (根據自己需要安裝相應模塊和插件)
make   (編譯)
make install   (安裝)

2) 依賴包源碼安裝(默認安裝的openssl、pcre等版本較低,可到官網下載較新穩定版源碼去安裝,安全性高點)
版本:redhat 7.4 ,zlib-1.2.8,pcre-8.34,nginx-1.14.0

[root@xsbfwbtest pcre-8.34]# ./configure
......
[root@xsbfwbtest pcre-8.34]# make
 cd . && /bin/sh /software/tools/pcre-8.34/missing automake-1.14 --gnu
/software/tools/pcre-8.34/missing: line 81: automake-1.14: command not found
WARNING: 'automake-1.14' is missing on your system.
         You should only need it if you modified 'Makefile.am' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'automake' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
make: *** [Makefile.in] Error 1
[root@xsbfwbtest pcre-8.34]# rpm -qa | grep automake
automake-1.13.4-3.el7.noarch
[root@xsbfwbtest pcre-8.34]# rpm -qa | grep automake
automake-1.13.4-3.el7.noarch
[root@xsbfwbtest pcre-8.34]# ll -ha /usr/bin/ | grep auto
autoconf       autoheader     autom4te       automake       automake-1.13  autoreconf     autoscan       autoupdate
[root@xsbfwbtest pcre-8.34]# ln -s /usr/bin/automake-1.13 /usr/bin/automake-1.14
[root@xsbfwbtest pcre-8.34]# ln -s /usr/bin/aclocal-1.13 /usr/bin/aclocal-1.14
[root@xsbfwbtest pcre-8.34]# make
 cd . && /bin/sh /software/tools/pcre-8.34/missing automake-1.14 --gnu
configure.ac:29: error: version mismatch.  This is Automake 1.13.4,
configure.ac:29: but the definition used by this AM_INIT_AUTOMAKE
configure.ac:29: comes from Automake 1.14.  You should recreate
configure.ac:29: aclocal.m4 with aclocal and run automake again.
WARNING: 'automake-1.14' is probably too old.
         You should only need it if you modified 'Makefile.am' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'automake' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
make: *** [Makefile.in] Error 1
[root@xsbfwbtest pcre-8.34]# cd ..
[root@xsbfwbtest pcre-8.34]# yum remove automake -y  #把系統原來的卸載
......
[root@xsbfwbtest pcre-8.34]# \rm /usr/bin/automake-1.14  #幹掉剛纔建的軟鏈接
[root@xsbfwbtest pcre-8.34]# \rm /usr/bin/aclocal-1.14
[root@xsbfwbtest tools]# tar -zxvf automake-1.14.tar.gz  #下載上面報錯需要的對應版本,試了不是對應版本報各種錯,然後卸載make uninstall再去老老實實安裝對應版本才通過,http://ftp.gnu.org/gnu/automake/
......
[root@xsbfwbtest tools]# cd automake-1.14/
[root@xsbfwbtest automake-1.14]# ./configure
.....額,又有報錯,要先下載裝相應依賴在繼續,m4-1.4.9.tar.gz -> export PATH=$PATH:/usr/local/bin -> autoconf-2.69.tar.gz
[root@xsbfwbtest automake-1.14]# ./configure
.....
[root@xsbfwbtest automake-1.14]# make && make install
......
[root@xsbfwbtest ~]# automake --version    #重新登錄下查看版本已經是1.14了 
automake (GNU automake) 1.14
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Tom Tromey <[email protected]>
       and Alexandre Duret-Lutz <[email protected]>.
[root@xsbfwbtest pcre-8.34]# ./configure   #進pcre目錄重新編譯安裝,
......
[root@xsbfwbtest pcre-8.34]# make 
......
[root@xsbfwbtest pcre-8.34]# make install
......
#下面源碼安裝nginx,參數可以根據自己需要加上。其中pcre和zlib我用的源碼安裝,也可以直接yum安裝
[root@xsbfwbtest nginx-1.14.0]# ./configure --prefix=/software/nginx-1.14 --user=nginx --group=nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-pcre=/software/tools/pcre-8.34 --with-http_realip_module --add-module=/software/tools/nginx_upstream_check_module-master --add-module=/software/tools/nginx-sticky-module-1.1-for1.14 --with-zlib=/software/tools/zlib-1.2.8 --with-http_ssl_module --with-stream
......
Configuration summary
  + using PCRE library: /software/tools/pcre-8.34
  + using system OpenSSL library
  + using zlib library: /software/tools/zlib-1.2.8

  nginx path prefix: "/software/nginx-1.14"
  nginx binary file: "/software/nginx-1.14/sbin/nginx"
  nginx modules path: "/software/nginx-1.14/modules"
  nginx configuration prefix: "/software/nginx-1.14/conf"
  nginx configuration file: "/software/nginx-1.14/conf/nginx.conf"
  nginx pid file: "/software/nginx-1.14/logs/nginx.pid"
  nginx error log file: "/software/nginx-1.14/logs/error.log"
  nginx http access log file: "/software/nginx-1.14/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@xsbfwbtest nginx-1.14.0]# make && make install
......
[root@xsbfwbtest conf]# vim nginx.conf   #進去剛纔安裝指定的目錄,配置根據自己需要修改
[root@xsbfwbtest sbin]# ./nginx -t  
nginx: the configuration file /software/nginx-1.14/conf/nginx.conf syntax is ok
nginx: configuration file /software/nginx-1.14/conf/nginx.conf test is successful
[root@xsbfwbtest sbin]# ./nginx
[root@xsbfwbtest sbin]# ps -ef | grep nginx
root     24080     1  0 12:21 ?        00:00:00 nginx: master process ./nginx
nginx    24081 24080  0 12:21 ?        00:00:00 nginx: worker process
root     24086  5316  0 12:21 pts/1    00:00:00 grep --color=auto nginx
[root@xsbfwbtest sbin]#

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章