|

WEB服务器1:Nginx

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时提供了IMAP/POP3/…

Nginx资源准备

1. 安装包资源

压缩包地址

wget http://nginx.org/download/nginx-1.22.1.tar.gz
tar -zxvf nginx-1.22.1.tar.gz

rpm包地址

2. 用户资源

useradd -M -s /usr/sbin/nologin nginx

3. 编译环境

yum groupinstall "Development Tools" -y
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel nginx-mod-http2

Nginx安装

1. 编译安装

./configure --prefix=/etc/nginx --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gunzip_module --with-http_slice_module --with-http_secure_link_module --with-http_gzip_static_module --with-http_stub_status_module --with-threads --with-file-aio --with-pcre --with-stream

make && make install

2. rpm安装

wget http://nginx.org/packages/rhel/9/x86_64/RPMS/nginx-1.22.1-1.el9.ngx.x86_64.rpm
rpm -ivh --nodeps nginx-1.22.1-1.el9.ngx.x86_64.rpm

Nginx管理命令

cp /etc/nginx/sbin/nginx /usr/bin/nginx
nginx -s reload
nginx
nginx -s stop

Nginx服务

  • 重载系统服务:systemctl daemon-reload
  • 服务命令:systemctl [options] nginx(start | status | stop | restrart | enable | disable)
sudo tee /etc/systemd/system/nginx.service  << EOF 
[Unit]
Description=The NGINX HTTP and reverse proxy server 
After=syslog.target  network.target
 
[Service]
Type=forking 
ExecStartPre=/www/nginx/sbin/nginx -t 
ExecStart=/www/nginx/sbin/nginx 
ExecReload=/www/nginx/sbin/nginx -s reload 
ExecStop=/bin/kill -s QUIT \$MAINPID 
PrivateTmp=true 
 
[Install]
WantedBy=multi-user.target

EOF

类似文章