wget http://nginx.org/download/nginx-1.15.9.tar.gz
wget http://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
wget http://www.zlib.net/fossils/zlib-1.2.11.tar.gz
tar -xzvf pcre-8.43.tar.gz -C /usr/local/myapps
tar -xzvf zlib-1.2.11.tar.gz -C /usr/local/myapps
tar -xzvf nginx-1.15.9.tar.gz
yum -y install gcc-c++
cd nginx-1.15.9/
./configure --prefix=/usr/local/myapps/nginx --sbin-path=/usr/sbin/nginx --pid-path=/usr/local/myapps/nginx/logs/nginx.pid --error-log-path=/usr/local/myapps/nginx/logs/error.log --http-log-path=/usr/local/myapps/nginx/logs/access.log --with-pcre=/usr/local/myapps/pcre-8.43 --with-zlib=/usr/local/myapps/zlib-1.2.11 --with-http_stub_status_module --with-stream
make && make install
参数说明:
--with-http_stub_status_module 加载性能统计模块
--with-stream 加载四层负载均衡支持模块
nginx -V
groupadd www
useradd -M -g www -s /sbin/nologin www
mv /usr/local/myapps/nginx/conf/nginx.conf /usr/local/myapps/nginx/conf/nginx.conf_bak
mkdir /usr/local/myapps/nginx/conf/vhosts/
cat << EOF >/usr/local/myapps/nginx/conf/nginx.conf
user www www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for‘;
sendfile on;
keepalive_timeout 65;
include /usr/local/myapps/nginx/conf/vhosts/http*.conf;
}
stream {
include /usr/local/myapps/nginx/conf/vhosts/tcp*.conf;
}
EOF
9.检查配置文件的正确性
nginx -t
nginx -c /usr/local/myapps/nginx/conf/nginx.conf
ps -ef | grep nginx | grep -v grep | awk ‘{print $2}‘ |xargs kill -9
nginx -s reload
原文:https://www.cnblogs.com/jipinglong/p/11227651.html