nginx编译安装教程

有个需求,要是用nginx的反向代理功能。以前有使用过lnmp,但是这些还用不上,就先自己安装一个单独的nginx服务器就好了。 下载nginx 首先从http://wiki.nginx.org/InstallChs下载源代码。我下载的是http://nginx.org/download/nginx-1.0.2.tar.gz wget http://nginx.org/download/nginx-1.0.2.tar.gz 解压缩安装

tar -zxvf nginx-1.0.2.tar.gz
./configure

出现问题。说

checking for PCRE library … not found checking for PCRE library in /usr/local/ … not found checking for PCRE library in /usr/include/pcre/ … not found checking for PCRE library in /usr/pkg/ … not found checking for PCRE library in /opt/local/ … not found ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by usingwithout-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by usingwith-pcre= option.

运行yum命令

yum install pcre-devel

也可以参考安装教程http://www.asep.us/2011/05/30/nginx-instalation-pcre-library-not-found/ 出现gzip 类库

./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by usingwithout-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by usingwith-zlib= option.

yum安装

yum install zlib zlib-devel

或者自己编译安装,下载地址:http://zlib.net/zlib-1.2.7.tar.gz 继续安装

你可能还会使用openssl组件,

yum install openssl openssl-devel
./configure --with-http_ssl_module --with-ipv6
make
make install

启动nginx /usr/local/nginx/sbin/nginx 关闭nginx /usr/local/nginx/sbin/nginx -s stop 几个常用的命令

Nginx -s stop         快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。(quick exit)
Nginx -s quit         平稳关闭Nginx,保存相关信息,有安排的结束web服务。(graceful exit)
Nginx -s reload       因改变了Nginx相关配置,需要重新加载配置而重载。(changing configuration,start a new worker,quitting an old worker gracefully.)
Nginx -s reopen       重新打开日志文件。(reopenging log files)

转自: nginx编译安装教程 – https://www.chenyudong.com/archives/nginx-install.html

你可能感兴趣的:(linux)