Linux 安装 nginx

来源:互联网 发布:三国志11全人物数据 编辑:程序博客网 时间:2024/05/29 19:06

Nginx包和依赖包下载

模块依赖性Nginx需要依赖下面3个包

  1. gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )

  2. rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )

  3. ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )

    nginx包(下载:http://nginx.org/en/download.html)

废话不多说,安装Nginx开始
(通过wget下载所有的包,具体包的版本可根据实际情况选择)

第一步:下载包

[root@localhost xx]# wget http://www.openssl.org/source/openssl-fips-2.0.9.tar.gz[root@localhost xx]# wget http://zlib.net/zlib-1.2.11.tar.gz[root@localhost xx]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz[root@localhost xx]# wget http://nginx.org/download/nginx-1.8.0.tar.gz

第二步安装:顺序为 openssl, zlib, pcre, nginx
安装openssl

[root@localhost xx]# tar -zxvf openssl-fips-2.0.9.tar.gz [root@localhost xx]# cd openssl-fips-2.0.9[root@localhost openssl-fips-2.0.9]# ./config && make && make install

安装zlib

[root@localhost xx]# tar -zxvf zlib-1.2.11.tar.gz [root@localhost xx]# cd zlib-1.2.11[root@localhost zlib-1.2.11]# ./configure && make && make install

安装pcre

[root@localhost xx]# tar -zxvf pcre-8.39.tar.gz [root@localhost xx]# cd pcre-8.39[root@localhost pcre-8.39]# ./configure && make && make install

安装nginx

[root@localhost xx]# tar -zxvf nginx-1.8.0.tar.gz [root@localhost xx]# cd nginx-1.8.0[root@localhost nginx-1.8.0]# ./configure --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-fips-2.0.9[root@localhost nginx-1.8.0]# make[root@localhost nginx-1.8.0]# make install

第三步:检测是否安装成功

[root@localhost nginx-1.8.0]# cd  /usr/local/nginx/sbin[root@localhost sbin]# ./nginx -t

出现如下所示提示,表示安装成功
这里写图片描述

启动nginx

[root@localhost sbin]# ./nginx

查看端口

[root@localhost sbin]# netstat -ntlp

这里写图片描述

参考文章:
1. http://www.cnblogs.com/hzh19870110/p/6100661.html
2. http://www.cnblogs.com/lovexinyi8/p/5845017.html

0 0