CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

时间:2022-03-27 04:37:48

 

 

 

 

  不多说,直接上干货!

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

[hadoop@djt002 local]$ su root
Password: 
[root@djt002 local]# ll
total 76
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 bin
drwxr-xr-x. 2 hadoop hadoop 4096 Mar 14 06:19 data
drwxr-xr-x. 3 hadoop hadoop 4096 Feb 21 23:10 elasticsearch
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 etc
drwxr-xr-x. 3 hadoop hadoop 4096 Jan 17 17:14 flume
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 games
drwxr-xr-x. 3 hadoop hadoop 4096 Jan 16 23:33 hadoop
drwxr-xr-x. 3 hadoop hadoop 4096 Mar 16 18:26 hbase
drwxr-xr-x. 4 hadoop hadoop 4096 Mar 14 17:48 hive
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 include
drwxr-xr-x. 3 hadoop hadoop 4096 Jan 16 23:25 jdk
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 lib
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 lib64
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 libexec
drwxr-xr-x  4 hadoop hadoop 4096 Apr 28 22:07 mahout
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 sbin
drwxr-xr-x. 5 root   root   4096 Jan 16 20:09 share
drwxr-xr-x. 4 hadoop hadoop 4096 Mar 17 23:33 sqoop
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 src

 

 

 

 CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

[root@djt002 local]# pwd
/usr/local
[root@djt002 local]# ll
total 76
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 bin
drwxr-xr-x. 2 hadoop hadoop 4096 Mar 14 06:19 data
drwxr-xr-x. 3 hadoop hadoop 4096 Feb 21 23:10 elasticsearch
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 etc
drwxr-xr-x. 3 hadoop hadoop 4096 Jan 17 17:14 flume
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 games
drwxr-xr-x. 3 hadoop hadoop 4096 Jan 16 23:33 hadoop
drwxr-xr-x. 3 hadoop hadoop 4096 Mar 16 18:26 hbase
drwxr-xr-x. 4 hadoop hadoop 4096 Mar 14 17:48 hive
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 include
drwxr-xr-x. 3 hadoop hadoop 4096 Jan 16 23:25 jdk
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 lib
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 lib64
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 libexec
drwxr-xr-x  4 hadoop hadoop 4096 Apr 28 22:07 mahout
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 sbin
drwxr-xr-x. 5 root   root   4096 Jan 16 20:09 share
drwxr-xr-x. 4 hadoop hadoop 4096 Mar 17 23:33 sqoop
drwxr-xr-x. 2 root   root   4096 Sep 23  2011 src
[root@djt002 local]# rz

[root@djt002 local]# ll
total 892
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 bin
drwxr-xr-x. 2 hadoop hadoop   4096 Mar 14 06:19 data
drwxr-xr-x. 3 hadoop hadoop   4096 Feb 21 23:10 elasticsearch
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 etc
drwxr-xr-x. 3 hadoop hadoop   4096 Jan 17 17:14 flume
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 games
drwxr-xr-x. 3 hadoop hadoop   4096 Jan 16 23:33 hadoop
drwxr-xr-x. 3 hadoop hadoop   4096 Mar 16 18:26 hbase
drwxr-xr-x. 4 hadoop hadoop   4096 Mar 14 17:48 hive
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 include
drwxr-xr-x. 3 hadoop hadoop   4096 Jan 16 23:25 jdk
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 lib
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 lib64
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 libexec
drwxr-xr-x  4 hadoop hadoop   4096 Apr 28 22:07 mahout
-rw-r--r--  1 root   root   833473 Mar 20 10:24 nginx-1.8.1.tar.gz
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 sbin
drwxr-xr-x. 5 root   root     4096 Jan 16 20:09 share
drwxr-xr-x. 4 hadoop hadoop   4096 Mar 17 23:33 sqoop
drwxr-xr-x. 2 root   root     4096 Sep 23  2011 src
[root@djt002 local]# 

 

 

 

 

1、gzip 模块需要 zlib 库 ( 下载: http://www.zlib.NET/ )
2、rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )
3、ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )

依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包

我这里的话,Nginx包我本地下载好了,我就直接用rz命令上传就好了,其他三个我在线下载过来

分别用:(下面有过程截图)

wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz

wget http://zlib.net/zlib-1.2.11.tar.gz

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

 

 

 

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

[root@djt002 local]# wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
--2017-06-08 07:52:03--  http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
Resolving www.openssl.org... 104.77.19.105, 2600:1417:76:18c::c1e, 2600:1417:76:181::c1e
Connecting to www.openssl.org|104.77.19.105|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.openssl.org/source/openssl-fips-2.0.10.tar.gz [following]
--2017-06-08 07:52:05--  https://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
Connecting to www.openssl.org|104.77.19.105|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1454240 (1.4M) [application/x-gzip]
Saving to: “openssl-fips-2.0.10.tar.gz”

100%[=====================================================================================================================================================>] 1,454,240    401K/s   in 3.5s    

2017-06-08 07:52:11 (401 KB/s) - “openssl-fips-2.0.10.tar.gz” saved [1454240/1454240]

[root@djt002 local]# wget http://zlib.net/zlib-1.2.11.tar.gz
--2017-06-08 07:52:23--  http://zlib.net/zlib-1.2.11.tar.gz
Resolving zlib.net... 69.73.182.198
Connecting to zlib.net|69.73.182.198|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 607698 (593K) [application/x-gzip]
Saving to: “zlib-1.2.11.tar.gz”

100%[=====================================================================================================================================================>] 607,698     8.17K/s   in 78s     

2017-06-08 07:53:42 (7.64 KB/s) - “zlib-1.2.11.tar.gz” saved [607698/607698]

[root@djt002 local]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
--2017-06-08 07:53:48--  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
           => “pcre-8.40.tar.gz”
Resolving ftp.csx.cam.ac.uk... 131.111.8.115
Connecting to ftp.csx.cam.ac.uk|131.111.8.115|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/software/programming/pcre ... done.
==> SIZE pcre-8.40.tar.gz ... 2065161
==> PASV ... done.    ==> RETR pcre-8.40.tar.gz ... done.
Length: 2065161 (2.0M) (unauthoritative)

100%[=====================================================================================================================================================>] 2,065,161   15.6K/s   in 78s     

2017-06-08 07:55:12 (25.9 KB/s) - “pcre-8.40.tar.gz” saved [2065161]

[root@djt002 local]# ls
bin   elasticsearch  flume  hadoop  hive     jdk  lib64    mahout              openssl-fips-2.0.10.tar.gz  sbin   sqoop  zlib-1.2.11.tar.gz
data  etc            games  hbase   include  lib  libexec  nginx-1.8.1.tar.gz  pcre-8.40.tar.gz            share  src
[root@djt002 local]# 

 

查看下载的包,我们可以发现也是几个压缩包的形式存放在我们的linux系统里面

 

 

 

 

 

 

  如果没有安装c++编译环境,还得安装,通过yum install gcc-c++完成安装

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

[root@djt002 local]# yum -y install gcc-c++
Loaded plugins: fastestmirror, refresh-packagekit, security
Existing lock /var/run/yum.pid: another copy is running as pid 4884.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  48 M RSS (355 MB VSZ)
    Started: Thu Jun  8 08:17:45 2017 - 00:05 ago

期间会有确认提示输入y回车

Is this ok [y/N]:y

 

 

 

 

 

2、安装Nginx及相关组件

openssl安装

# tar -zxvf openssl-fips-2.0.10.tar.gz
# cd openssl-fips-2.0.10
# ./config && make && make install

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

 

 

 

 

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

  耐心等待。

 

 

 

 

pcre安装

# tar -zxvf pcre-8.40.tar.gz

# cd pcre-8.40

# ./configure && make && make install

 

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

 

 

 CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

 

 

 

 





zlib安装

# tar -zxvf zlib-1.2.11.tar.gz

# cd zlib-1.2.11

 #./configure && make && make install
 

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

 

 

 

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

     其实三个插件包操作起来差不多的!

 

 

 

 

nginx安装

通过命令解压

tar -zxvf nginx-1.8.1.tar.gz 

cd nginx-1.8.1

./configure && make && make install

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

 

 CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

 

 

 

 

 

 

 

 

 

3、启动Nginx

  先找一下nginx安装到什么位置上了通过  whereis nginx命令来查找,然后进入相应的目录下用sbin/nginx启动

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

[root@djt002 nginx-1.8.1]# whereis nginx
nginx: /usr/local/nginx
[root@djt002 nginx-1.8.1]# cd /usr/local/nginx
[root@djt002 nginx]# pwd
/usr/local/nginx
[root@djt002 nginx]# ls
conf  html  logs  sbin
[root@djt002 nginx]# ll
total 16
drwxr-xr-x 2 root root 4096 Jun  8 08:27 conf
drwxr-xr-x 2 root root 4096 Jun  8 08:27 html
drwxr-xr-x 2 root root 4096 Jun  8 08:27 logs
drwxr-xr-x 2 root root 4096 Jun  8 08:27 sbin
[root@djt002 nginx]# sbin/nginx 
sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@djt002 nginx]# 

 

   报错了,error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,按照下面方式解决

1.用whereis libpcre.so.1命令找到libpcre.so.1在哪里

2.用ln -s /usr/local/lib/libpcre.so.1 /lib64命令做个软连接就可以了

3.用sbin/nginx启动Nginx

4.用ps -aux | grep nginx查看状态

 

 

CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)

[root@djt002 nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so /usr/local/lib/libpcre.so.1
[root@djt002 nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@djt002 nginx]# sbin/nginx
[root@djt002 nginx]# ps -aux | grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      13324  0.0  0.0  20264   624 ?        Ss   08:29   0:00 nginx: master process sbin/nginx
nobody    13325  0.0  0.1  20692  1208 ?        S    08:29   0:00 nginx: worker process
root      13327  0.0  0.0 103252   832 pts/0    S+   08:29   0:00 grep nginx
[root@djt002 nginx]# 

 

 

 

 

 

 

  进入Linux系统的图形界面,打开浏览器输入localhost会看到下图,说明nginx启动成功(这个时候体现了安装linux的时候还是安装桌面版的好处了)

 CentOS6.5下nginx-1.8.1.tar.gz的单节点搭建(图文详解)