自编译安装nginx

Posted pautcher

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自编译安装nginx相关的知识,希望对你有一定的参考价值。

1. 下载nginx,并解压

http://nginx.org/

2. 下载health check模块

git clone https://github.com/yaoweibin/nginx_upstream_check_module.git

3. 安装依赖模块包,配置预编译环境

yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

建立nginx 组
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
id nginx

zlib:nginx提供gzip模块,需要zlib库支持
openssl:nginx提供ssl功能
pcre:支持地址重写rewrite功能

4. 进入nginx解压目录,开始编译

*注意最后一个add-module,是编译加上health check模块

./configure \
--prefix=/opt/apps_install \
--sbin-path=/usr/sbin/nginx \
--conf-path=/opt/conf/nginx/nginx.conf \
--error-log-path=/opt/logs/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-log-path=/opt/logs/nginx/access.log \
--http-client-body-temp-path=/opt/apps_install/nginx/client_body_temp \
--http-proxy-temp-path=/opt/apps_install/nginx/proxy_temp \
--http-fastcgi-temp-path=/opt/apps_install/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/opt/apps_install/nginx/uwsgi_temp \
--http-scgi-temp-path=/opt/apps_install/nginx/scgi_temp \
--with-http_stub_status_module \
--add-module=/home/nginx-1.10.2/nginx_upstream_check_module
 
五、make && make install

六、常见问题

在配置nginx提示如下错误时:
[emerg]: getpwnam(“nginx”) failed
解决方案:
nginx用户没有创建和打开,执行3中的创建nginx用户和给予权限即可











以上是关于自编译安装nginx的主要内容,如果未能解决你的问题,请参考以下文章

Linux编译安装nginx并平滑升级和回滚

nginx 编译安装详解

自编译安装nginx

Linux下Nginx编译安装后的开机自启动设置

Lamp架构nginxphpmysql源码编译安装

Lamp架构nginxphpmysql源码编译安装