编译nginx

下载

http://nginx.org/download/nginx-1.16.1.tar.gz

依赖

yum -y install gcc gcc-c++ autoconf automake make      
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

添加运行用户

groupadd -f www
useradd -g www www
# 如果没有可能会报错nginx: [emerg] getpwnam(“www”) failed

编译

tar xvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-http_gzip_static_module --with-http_sub_module
make && make install

# http_stub_status_module  状态监控
# http_ssl_module    配置https
# stream  配置tcp得转发
# http_gzip_static_module 压缩
# http_sub_module  替换请求

设置配置文件

mkdir -p /etc/nginx/{conf,conf.d}
mv /usr/local/nginx/conf/* /etc/nginx/conf/

开机自启service

cat > /etc/systemd/system/nginx.service <
systemctl daemon-reload
systemctl enable nginx
systemctl start nginx

你可能感兴趣的:(编译nginx)