mkdir -p /nulige/tools cd /nulige/tools wget https://nginx.org/download/nginx-1.16.0.tar.gz tar zxvf nginx-1.16.0.tar.gz cd nginx-1.16.0 ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module make && make install
[root@ansible-server sbin]# nginx -V nginx version: nginx/1.16.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
6、配置启动服务
1 2 3 4 5 6 7 8 9
[root@ansible-server conf]# vi /usr/lib/systemd/system/nginx.service [Unit] Description=nginx - high performance web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#重载并启动服务 [root@ansible-server conf]# systemctl daemon-reload [root@ansible-server conf]# systemctl start nginx [root@ansible-server conf]# systemctl enable nginx [root@ansible-server conf]# systemctl status nginx ● nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; static; vendor preset: disabled) Active: active (running) since Sat 2019-05-18 16:36:48 CST; 11s ago Main PID: 26928 (nginx) CGroup: /system.slice/nginx.service ├─26928 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf └─26929 nginx: worker process
May 18 16:36:48 ansible-server systemd[1]: Starting nginx - high performance web server... May 18 16:36:48 ansible-server systemd[1]: Started nginx - high performance web server.