nginx部署-源码
1、环境部署
1)下载源码包
https://nginx.org/download/nginx-1.21.1.tar.gz 版本:nginx-1.21.1
2)安装编译所需的程序
yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
3)解压源码包到指定目录
tar -zxvf nginx-1.21.1.tar.gz -C /usr/local/src/
2、编译安装
1)创建nginx目录及nginx用户
mkdir /usr/nginx
useradd nginx
2)编译环境
./configure \
--prefix=/nginx/nginx \
--sbin-path=/nginx/nginx/sbin/nginx \
--modules-path=/nginx/nginx/modules \
--conf-path=/nginx/nginx/conf/nginx.conf \
--error-log-path=/nginx/nginx/log/error.log \
--http-log-path=/nginx/nginx/log/access.log \
--pid-path=/nginx/nginx/nginx.pid \
--lock-path=/nginx/nginx/nginx.lock \
--http-client-body-temp-path=/nginx/nginx/client_temp \
--http-proxy-temp-path=/nginx/nginx/proxy_temp \
--http-fastcgi-temp-path=/nginx/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/nginx/nginx/uwsgi_temp \
--http-scgi-temp-path=/nginx/nginx/scgi_temp \
--with-compat \
--user=nginx \
--group=nginx \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--ngx_http_headers_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
3)安装
make && make install
4)启动nginx
/nginx/nginx/sbin/nginx -c /nginx/nginx/conf/nginx.conf
3、nginx控制
启动nginx
/nginx/nginx/sbin/nginx
关闭nginx
/nginx/nginx/sbin/nginx -s stop
重启nginx
/nginx/nginx/sbin/nginx -s reload
平滑加载nginx配置文件
kill -HUP `cat /nginx/nginx/nginx.pid`(nginx master process pid)
中间件自动安装脚本:
https://opszzfwordpress.club/post/119.html
nginx常用命令讲解视频: