Official website: http://nginx.org/
Click Download. Choose version campatible with your system. In this article, my system is Linux.

Nginx is written in C language. So make sure you have C language environment first.
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
Unzip the software package.
tar -zxvf nginx-1.10.0.tar.gz
Config the install path to /usr/local/nginx.
cd nginx-1.10.0
./configure --prefix=/usr/local/nginx
Compile and Install
make && make install
Start Nginx
cd /usr/local/sbin
./nginx
To close and dynamically load the configuration file, run the following commands:
./nginx -s stop
./nginx -s reload
Set Nginx to start automatically when system boot
vim /lib/systemd/system/nginx.service
Write these in the file.
[Unit]
Description=nginx
After=network.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 stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Save and quit.
Set starting service when system boot
systemctl daemon-reload # reload the service configuration
systemctl enable nginx.service # set start when boot
systemctl start nginx.service # start service
systemctl status nginx.service # check service status
systemctl stop nginx.service # stop service
0 Comments