首页 > 代码库 > nginx安装

nginx安装

安装

下载相关组件

下载nginx: wget http://nginx.org/download/nginx-1.x.x.tar.gz
下载openssl : wget http://www.openssl.org/source/openssl-fips-2.0.9.tar.gz
下载zlib : wget http://zlib.net/zlib-1.2.8.tar.gz
下载pcre : wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
如果没有安装c++编译环境,还得安装,通过yum install gcc-c++完成安装

编译安装

openssl :
[root@localhost] tar zxvf openssl-fips-2.0.9.tar.gz
[root@localhost] cd openssl-fips-2.0.9
[root@localhost] ./config && make && make install
pcre: [root@localhost] tar zxvf pcre
-8.36.tar.gz [root@localhost] cd pcre-8.36 [root@localhost] ./configure && make && make install zlib: [root@localhost] tar zxvf zlib-1.2.8.tar.gz [root@localhost] cd zlib-1.2.8 [root@localhost] ./configure && make && make install

nginx:
[root@localhost] tar zxvf nginx-1.8.0.tar.gz
[root@localhost] cd nginx-1.8.0
[root@localhost] ./configure  --prefix=/usr/local/nginx && make && make install

启动

/usr/local/nginx/sbin/nginx

做高可用

nginx+keeplived组合

第三方扩展组件安装

./configure --prefix=/你的安装目录  --add-module=/第三方模块目录

pagespeed模块安装样例:

未安装nginx情况下:

# ./configure --prefix=/usr/local/nginx-1.4.1 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --add-module=../ngx_pagespeed-master --add-module=/第三方模块目录
# make
# make isntall
# /usr/local/nginx-1.4.1/sbin/nginx

已安装nginx情况下:

# ./configure --prefix=/usr/local/nginx-1.4.1  --with-http_stub_status_module  --with-http_ssl_module --with-http_realip_module  --with-http_image_filter_module  --add-module=../ngx_pagespeed-master
# make
# /usr/local/nginx-1.4.1/sbin/nginx -s stop
# cp objs/nginx /usr/local/nginx/sbin/nginx
# /usr/local/nginx-1.4.1/sbin/nginx

第三方组件清单:https://www.nginx.com/resources/wiki/modules/index.html

nginx安装