有个需求,要是用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 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命令

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 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安装

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