Tutorial for installing Nginx servers on Linux and Windows systems

  • 2020-05-09 19:56:15
  • OfStack

1. Install Nginx on the CentOS system
In the CentOS6 version of the EPEL source, the rpm package of nginx has been added, although this RPM package is in a lower version. If you need an update, you can use the official rpm package, or you can use the source package to compile and install.

You can also use a version of nginx that has been enhanced twice, such as taobao's Tengine and OpenResty.
1.1 common compilation parameters

      --prefix=PATH: specifies the installation directory for nginx
      -- conf-path =PATH: specify the nginx.conf configuration file path
      --user=NAME: user of nginx worker process
      -- with-pcre: enable PCRE regular expression support
      -- with-http_ssl_module: start SSL support
      -- with-http_stub_status_module: used to monitor the status of Nginx
      -- with-http-realip_module: allows you to change the client IP address in the client request header
      -- with-file-aio: File AIO enabled
      -- add-module =PATH: add a third external module

Here is a complete compilation scheme:


--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client_body \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx \
--user=nginx \
--group=nginx \
--with-file-aio \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre

1.2 startup and shutdown of nginx

Start the nginx:


# nginx -c /etc/nginx/nginx.conf 

Close the nginx


# nginx -s stop

Reread configuration file


# nginx -s reload
# pkill -HUP nginx

Reopen the log file


# nginx -s reopen
# pkill -USR1 nginx

Can also download nginx RPM in/etc/init d/nginx file, modify the path can be used to:

# service nginx {start|stop|status|restart|reload|configtest|}

2. Install Nginx on the Windows system
First go to the website to download nginx1. 0.11 Windows version, download website: http: / / nginx org download/nginx - 1.0.11. zip


Once downloaded to the package, unpack the nginx-nginx1.0.11.zip package to your favorite root directory and change the directory name to nginx.

Then, do the following:


cd nginx

start nginx


Thus, the nginx service is started. Open the task manager and look at the nginx.exe process. There are two processes that will show up, occupying system resources, which is quite small. Then open your browser and type http://127.0.0.1/   to see the nginx welcome page, which is very friendly

nginx -s stop     //  stop nginx
nginx -s reload    //  Reload the configuration file 
nginx -s quit     //  exit nginx




Related articles: