版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/LBinin/article/details/70185131
Nginx安装:
下载解压安装
http://nginx.org/,进入后选择最新的版本,进入页面后在 Stable version
中选择 nginx-*
右键复制链接,然后用 wget
下载
[root@iZ2844brz0xZ ~]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
如果提示wget命令未找到,则执行
[root@iZ2844brz0xZ ~]# sudo yum install wget
下载完用 ll
命令查看刚刚下载获得的 nginx-*.tar.gz
文件,用下面命令解压它
[root@iZ2844brz0xZ ~]# tar -zxvf nginx-1.12.0.tar.gz
-z: 表示使用gzip的属性。
-x: 解开一个压缩文件的参数指令。
-v: 表示压缩的过程中显示文件!这个常用,但不建议用在背景执行过程!
-f: 使用档名,请留意,在 f 之后要立即接档名喔!不要再加参数!
安装Nginx前,需要安装以下三个依赖包:
gzip 模块需要 zlib 库
rewrite 模块需要 pcre 库
ssl 功能需要 openssl 库
https://www.openssl.org/source/
[root@iZ2844brz0xZ ~]# wget https://www.openssl.org/source/openssl-fips-2.0.14.tar.gz
[root@iZ2844brz0xZ ~]# wget http://www.zlib.net/zlib-1.2.11.tar.gz
[root@iZ2844brz0xZ ~]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
下载完成后安装,依赖包安装顺序依次为: openssl
、zlib
、pcre
, 然后安装 Nginx
包
1.安装openssl
[root@iZ2844brz0xZ ~]# tar -zxvf openssl-fips-2.0.14.tar.gz
[root@iZ2844brz0xZ ~]# cd openssl-fips-2.0.14/
[root@iZ2844brz0xZ openssl-fips-2.0.14]# ./config
[root@iZ2844brz0xZ openssl-fips-2.0.14]# make
[root@iZ2844brz0xZ openssl-fips-2.0.14]# make install
2.安装zlib
[root@iZ2844brz0xZ ~]# tar -zxvf zlib-1.2.11.tar.gz
[root@iZ2844brz0xZ ~]# cd zlib-1.2.11/
[root@iZ2844brz0xZ zlib-1.2.11]# ./configure
[root@iZ2844brz0xZ zlib-1.2.11]# make
[root@iZ2844brz0xZ zlib-1.2.11]# make install
3.安装pcre
[root@iZ2844brz0xZ ~]# tar -zxvf pcre-8.39.tar.gz
[root@iZ2844brz0xZ ~]# cd pcre-8.39/
[root@iZ2844brz0xZ pcre-8.39]# ./configure
[root@iZ2844brz0xZ pcre-8.39]# make
[root@iZ2844brz0xZ pcre-8.39]# make install
4.安装nginx
[root@iZ2844brz0xZ ~]# tar -zxvf nginx-1.12.0.tar.gz
[root@iZ2844brz0xZ ~]# cd nginx-1.12.0/
[root@iZ2844brz0xZ nginx-1.12.0]# ./configure --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-fips-2.0.14
[root@iZ2844brz0xZ nginx-1.12.0]# make
[root@iZ2844brz0xZ nginx-1.12.0]# make install
检测是否安装成功
[root@iZ2844brz0xZ nginx-1.12.0]# cd /usr/local/nginx/sbin/
[root@iZ2844brz0xZ sbin]# ./nginx -t
若出现下方信息表示安装成功
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
最后一步:启动Nginx
[root@iZ2844brz0xZ sbin]# ./nginx
查看端口
[root@iZ2844brz0xZ sbin]# netstat -ntlp
出现以下结果
至此,Nginx安装结束
参考资料:
http://www.cnblogs.com/hzh19870110/p/6100661.html 作者:grhlove123