系统配置
CentOS 5.4
nginx-1.1.11(下载地址:http://nginx.org/en/download.html)
openssl http://www.openssl.org/source/
安装步骤
解压文件,然后进入解压后的目录下,进行编译安装
tar -xzvf nginx-1.1.11.tar.gz
cd nginx-1.1.11
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-openssl=/root/softs/openssl-1.0.1
make
make install
以上就完成了nginx的安装过程,nginx的默认安装目录为/usr/local/nginx
Nginx的启动、停止
启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
参数"-c"指定了配置文件的路径,如果没有"-c",nginx默认会加载其安装目录的conf子目录中的nginx.conf文件。所以默认情况下可以不加"-c"启动。
停止:
通过ps -ef|grep nginx查看nginx的进程。在进程列表里面找master进程,它的编号就是主进程号了。
(1)从容停止Nginx:
kill -QUIT 主进程号
kill -QUIT /usr/local/nginx/logs/nginx.pid
(2)快速停止Nginx:
kill -TERM 主进程号
kill -TERM /usr/local/nginx/logs/nginx.pid
(3)强制停止Nginx:
pkill -9 nginx
Nginx的configure脚本支持选项说明:
./configure --help
–prefix=<path> - 安装路径,如果没有指定,默认为/usr/local/nginx。
–sbin-path=<path> - nginx可执行命令的文件,如果没有指定,默认为<prefix>/sbin/nginx。
–conf-path=<path> - 在没有使用-c参数指定的情况下nginx.conf的默认位置,如果没有指定,默认为<prefix>/conf/nginx.conf。
–pid-path=<path> - nginx.pid的路径,如果没有在nginx.conf中通过“pid”指令指定,默认为<prefix>/logs/nginx.pid。
–lock-path=<path> - nginx.lock文件路径,如果没有指定,默认为<prefix>/logs/nginx.lock。
–error-log-path=<path> - 当没有在nginx.conf中使用“error_log”指令指定时的错误日志位置,如果没有指定,默认为<prefix>/logs/error.log。
–http-log-path=<path> - 当没有在nginx.conf中使用“access_log”指令指定时的访问日志位置,如果没有指定,默认为<prefix>/logs/access.log。
–user=<user> - 当没有在nginx.conf中使用“user”指令指定时nginx运行的用户,如果没有指定,默认为“nobody”。
–group=<group> - 当没有在nginx.conf中使用“user”指令指定时nginx运行的组,如果没有指定,默认为“nobody”。
–builddir=DIR - 设置构建目录。
–with-rtsig_module - 启用rtsig模块。
–with-select_module –without-select_module - 如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,select模块始终为启用状态。
–with-poll_module –without-poll_module - 如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,poll模块始终为启用状态。
–with-http_ssl_module - 启用ngx_http_ssl_module,启用SSL支持并且能够处理HTTPS请求。需要OpenSSL,在Debian系统中,对应的包为libssl-dev。
–with-http_realip_module - 启用ngx_http_realip_module
–with-http_addition_module - 启用ngx_http_addition_module
–with-http_sub_module - 启用ngx_http_sub_module
–with-http_dav_module - 启用ngx_http_dav_module
–with-http_flv_module - 启用ngx_http_flv_module
–with-http_stub_status_module - 启用”server status”(服务状态)页
–without-http_charset_module - 禁用ngx_http_charset_module
–without-http_gzip_module - 禁用ngx_http_gzip_module,如果启用,需要zlib包。
–without-http_ssi_module - 禁用ngx_http_ssi_module
–without-http_userid_module - 禁用ngx_http_userid_module
–without-http_access_module - 禁用ngx_http_access_module
–without-http_auth_basic_module - 禁用ngx_http_auth_basic_module
–without-http_autoindex_module - 禁用ngx_http_autoindex_module
–without-http_geo_module - 禁用ngx_http_geo_module
–without-http_map_module - 禁用ngx_http_map_module
–without-http_referer_module - 禁用ngx_http_referer_module
–without-http_rewrite_module - 禁用ngx_http_rewrite_module。如果启用,需要PCRE包。
–without-http_proxy_module - 禁用ngx_http_proxy_module
–without-http_fastcgi_module - 禁用ngx_http_fastcgi_module
–without-http_memcached_module - 禁用ngx_http_memcached_module
–without-http_limit_zone_module - 禁用ngx_http_limit_zone_module
–without-http_empty_gif_module - 禁用ngx_http_empty_gif_module
–without-http_browser_module - 禁用ngx_http_browser_module
–without-http_upstream_ip_hash_module - 禁用ngx_http_upstream_ip_hash_module
–with-http_perl_module - 启用ngx_http_perl_module
–with-perl_modules_path=PATH - 为perl模块设置路径
–with-perl=PATH - 为perl库设置路径
–http-client-body-temp-path=PATH - 为http连接的请求实体临时文件设置路径,如果没有指定,默认为<prefix>/client_body_temp
–http-proxy-temp-path=PATH - 为http代理临时文件设置路径,如果没有指定,默认为<prefix>/proxy_temp
–http-fastcgi-temp-path=PATH - 为http fastcgi临时文件设置路径,如果没有指定,默认为<prefix>/fastcgi_temp
–without-http - 禁用HTTP服务
–with-mail - 启用IMAP4/POP3/SMTP代理模块
–with-mail_ssl_module - 启用ngx_mail_ssl_module
–with-cc=PATH - 设置C编译器路径
–with-cpp=PATH - 设置C预处理器路径
–with-cc-opt=OPTIONS - 变量CFLAGS中附加的参数,用于FreeBSD中的PCRE库,同样需要指定–with-cc-opt=”-I /usr/local/include”,如果我们使用select()函数则需要同时增加文件描述符数量,可以通过–with-cc-opt=”-D FD_SETSIZE=2048”指定。
–with-ld-opt=OPTIONS - 通过连接器的附加参数,用于FreeBSD中的PCRE库,同样需要指定–with-ld-opt=”-L /usr/local/lib”。
–with-cpu-opt=CPU - 指定编译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
–without-pcre - 禁用PCRE库文件,同时将禁用HTTP rewrite 模块,如果要在”location”指令中使用正则表达式,同样需要PCRE库。
–with-pcre=DIR - 设置PCRE库源文件路径。
–with-pcre-opt=OPTIONS - 在编译时为PCRE设置附加参数。
–with-md5=DIR - 设置md5库源文件路径。
–with-md5-opt=OPTIONS - 在编译时为md5设置附加参数。
–with-md5-asm - 使用md5汇编源。
–with-sha1=DIR - 设置sha1库源文件路径。
–with-sha1-opt=OPTIONS - 在编译时为sha1设置附加参数。
–with-sha1-asm - 使用sha1汇编源。
–with-zlib=DIR - 设置zlib库源文件路径。
–with-zlib-opt=OPTIONS - 在编译时为zlib设置附加参数。
–with-zlib-asm=CPU - 为指定的CPU使用zlib汇编源进行优化,可用值为: pentium, pentiumpro。
–with-openssl=DIR - 设置openssl库源文件路径。
–with-openssl-opt=OPTIONS - 在编译时为openssl设置附加参数。
–with-debug - 启用debug记录。
–add-module=PATH - 增加一个在PATH中的第三方模块。
安装过程中出现的错误及解决办法
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决办法:yum -y install pcre-devel
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
解决办法:yum install -y zlib-devel
分享到:
相关推荐
Ubuntu中Nginx服务器安装配置教程
Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。 本文档介绍 Nginx的基本安装与配置。
Nginx 在工作中已经有好几个环境在使用了,每次都是重新去网上找博客,各种编译配置,今天自己也整理一份安装文档和 nginx.conf 配置选项的说明,已作参考
轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器; 占有内存少,并发能力强,低消耗资源; 安全,稳定。
Nginx服务器的安装与配置Nginx服务器的安装与配置
第2章 Nginx服务器的安装与配置.pdf 第3章 Nginx的基本配置与优化.pdf 第4章 Nginx与PHP(FastCGI)的安装、配置与优化.pdf 第5章 Nginx与JSP、ASP.NET、Perl的安装与配置.pdf 第6章 Nginx HTTP负载均衡和反向代理的...
主要介绍了Nginx服务器安装及配置文件与使用详解 ,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Linux下安装nginx服务器
此文档介绍了nginx在linux下的安装与配置,文档中包含安装时所需其他安装包的百度网盘下载地址和提取码,并附有几个安装时遇到的问题
第2章Nginx服务器安装与配置;第3章Nginx基本配置与优化;第4章Nginx与PHP;第5章Nginx与JSP、ASP.NET..第6章Nginx http负载均衡和反向代理;第7章Nginx 的rewrite规则与实例;第8章 Nginx 模块开发;第9章Nginx 的...
1.Apache服务器安装SSL证书 2.IIS服务器安装SSL证书 3.Nginx服务器安装SSL证书 4.Tomcat服务器安装SSL证书
nginx服务器 linux 版本 2013.01.19
手把手ubunt下安装nginx web服务器,包括安装前提;nginx源码下载以及目录结构认识;nginx的编译和安装;nginx的启动和简单使用
nginx(engine x) 是一个 高性能 的 HTTP 和 反向代理 服务器、邮件代理服务器以及通用的 TCP/UDP 代理服务器。这篇文章主要介绍了Linux 系统 nginx 服务器安装及负载均衡配置详解,需要的朋友可以参考下
Nginx 在工作中已经有好几个环境在使用了,每次都是重新去网上找博客,各种编译配置,今天自己也整理一份安装文档和 nginx.conf 配置选项的说明,留作以后参考。 1. 安装nginx 1.1 选择稳定版本 我们编译安装nginx...
该资源包括nginx服务器,设置nginx服务为windows服务开机自启动方法说明
淘宝Tengine 易运维的高性能Nginx服务器