1. Install the PCRE and zlib libraries
# yum -y install PCRE pcre-devel yum install -y zlib-develCopy the code
2. Download the Nginx
Wget https://nginx.org/download/nginx-1.14.0.tar.gz # extract tar - XVZF nginx - 1.14.0. Tar. GzCopy the code
3. Download OpenSSL
Wget https://www.openssl.org/source/openssl-1.1.1-pre5.tar.gz # extract tar - XVZF openssl - 1.1.1 - pre5. Tar. Gz mv Openssl - 1.1.1 - pre5 / usr/local /Copy the code
4. Compile Nginx
/configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-openssl=/usr/local/openssl-1.1.1-pre5Copy the code
5. The Nginx directory after installation
/usr/local/nginx # CD /usr/local/nginx/sbin. /nginxCopy the code
Common commands
/nginx -s reload # restart./nginx -s stop # stopCopy the code
It comes with an automatic startup service
Add a custom service using systemctl
Add nginx.service to the /usr/lib/systemd/system directory
nginx.service
[Unit]
Description=nginx
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Copy the code
Common Service Commands
Service: systemctl start nginx.service: systemctl start nginx.service Service: systemctl reload nginx.serviceCopy the code