shisgmei 发表于 2018-11-10 06:32:50

Nginx1.14.0 编译安装

参考资料
  1、http://www.runoob.com/linux/nginx-install-setup.html
安装编译工具及库文件
  yum -y install make zlib zlib-devel gcc-c++ libtoolopenssl openssl-devel pcre pcre-devel
  ./configure--group=nginx--user=nginx--prefix=/usr/local/app/nginx_v/nginx-1.14.0--with-http_stub_status_module--with-http_ssl_module
  看编译看,还要编译zlib,pcre的,不知道为什么原因,
  http://www.pcre.org/
  http://zlib.net/
  编译pcre
  编译zlib
  ./configure--group=nginx--user=nginx--prefix=/usr/local/app/nginx_v/nginx-1.14.0--with-http_stub_status_module--with-http_ssl_module--with-http_gzip_static_module--with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.11
  这里指定的with-pcre 和with-zlib的路径不能他们编译指定的--prefix路径,而是其解压的用来编译的路径。
  这里我写的配置参数错了,就重新跑下./configure,会去重新生成makefile文件。
  然后删除之前安装的目录,再次执行make &&make install即可
  编译后目录结构如下。

  启动服务
  cd /usr/local/ewifi/nginx_v/nginx-1.14.0/sbin/
  ./nginx
  这里注意的是默认监听端口80,要查看此接口是否被占用,而且最好不要用默认端口。修改端口后再启动。
常见问题:
  1、默认,不指定pcre路径时。
  ./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= option.
  需要安装pcre-devel所以说,安装前准备工作要做好。
  2、nginx: getpwnam("nginx") failed
  说明编译时指定的用户没有创建,创建即可

页: [1]
查看完整版本: Nginx1.14.0 编译安装