安装nginx
Yum 安装
参考http://nginx.org/en/linux_packages.html
编译安装nginx
系统首先要安装gcc* 包以及一些依赖包
[root@wx-a tool]# wget http://nginx.org/download/nginx-1.8.0.tar.gz
[root@wx-a tool]# tar xf nginx-1.8.0.tar.gz -C /usr/local/src/
[root@wx-a tool]# cd /usr/local/src/nginx-1.8.0/
[root@wx-a nginx-1.8.0]#
备注: 每个版本不一样,默认安装的模块可能有所不同
详细可参考官网:
http://nginx.org/en/docs/configure.html
或者
[root@wx-a nginx-1.8.0]# ./configure –help 根据需求选择需要的模块
[root@wx-a nginx-1.8.0]# yum install gcc* pcre pcre-devel openssl openssl-devel zlibzlib-devel –y
[root@wx-a nginx-1.8.0]# useradd nginx -s /sbin/nologin –M
[root@wx-a nginx-1.8.0]# ./configure --prefix=/usr/local/webserver/nginx--with-http_ssl_module --with-http_flv_module --with-http_gunzip_module --with-http_stub_status_module
[root@wx-a nginx-1.8.0]# make && make install
make[1]: Leaving directory `/usr/local/src/nginx-1.8.0‘
查看nginx安装的模块
[root@wx-a nginx-1.8.0]#/usr/local/webserver/nginx/sbin/nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/webserver/nginx--with-http_ssl_module --with-http_flv_module --with-http_gunzip_module--with-http_stub_status_module
nginx 编译根据业务需要需要开启的模块
--with-http_ssl_module enable ngx_http_ssl_module
--with-http_spdy_module enable ngx_http_spdy_module
--with-http_realip_module enable ngx_http_realip_module
--with-http_addition_module enable ngx_http_addition_module
--with-http_xslt_module enable ngx_http_xslt_module
--with-http_image_filter_module enable ngx_http_image_filter_module
--with-http_geoip_module enable ngx_http_geoip_module
--with-http_sub_module enable ngx_http_sub_module
--with-http_dav_module enable ngx_http_dav_module
--with-http_flv_module enable ngx_http_flv_module
--with-http_mp4_module enable ngx_http_mp4_module
--with-http_gunzip_module enable ngx_http_gunzip_module
--with-http_gzip_static_module enable ngx_http_gzip_static_module
--with-http_auth_request_module enable ngx_http_auth_request_module
--with-http_random_index_module enable ngx_http_random_index_module
--with-http_secure_link_module enable ngx_http_secure_link_module
--with-http_degradation_module enable ngx_http_degradation_module
--with-http_stub_status_module enable ngx_http_stub_status_module
Nginx如何添加未编译的模块
重新编译
[root@wx-a nginx-1.8.0]# ./configure --prefix=/usr/local/webserver/nginx--with-http_ssl_module --with-http_flv_module --with-http_gunzip_module--with-http_stub_status_module --with-http_realip_module --with-http_flv_module && make
[root@wx-a nginx-1.8.0]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
#make 完成之后会生成一个objs目录会多出一个nginx,他就是新编译成的nginx程序,只需要将objs/nginx 拷贝到/usr/local/webserver/nginx/sbin/ 覆盖原有的nginx程序即可
如果此时nginx在运行的将nginx关闭,然后备份原有的nginx程序
[root@wx-a objs]# cp/usr/local/webserver/nginx/sbin/nginx /usr/local/webserver/nginx/sbin/nginx.bak
拷贝新的nginx程序覆盖原有的nginx
[root@wx-a nginx-1.8.0]# cp objs/nginx /usr/local/webserver/nginx/sbin/nginx
cp: overwrite `/usr/local/webserver/nginx/sbin/nginx‘? y
查看编译模块
[root@wx-a nginx-1.8.0]#/usr/local/webserver/nginx/sbin/nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/webserver/nginx--with-http_ssl_module --with-http_flv_module --with-http_gunzip_module--with-http_stub_status_module --with-http_realip_module --with-http_flv_module
第三方模块的安装
https://www.nginx.com/resources/wiki/modules/index.html
本文出自 “小菜鸟” 博客,转载请与作者联系!
原文地址:http://xiaocainiaox.blog.51cto.com/4484443/1701326