Install Nginx on Linux

1. Download the Nginx installation package

Nginx.org/en/download…

2. Install the dependency

yum -y install pcre pcre-devel

yum -y install openssl openssl-devel

yum -y install zlib zlib-devel

Pcre and pcre-devel: there must be a relationship between pcre and pcre-devel. Pcre is an online product, and pcre-devel(develop) is a development version. There are some functions that are not available in the online product

Pcre: Includes the Perl-compatible regular expression library

Openssl: Support for secure transport protocol HTTPS (the protocol for financial related requests)

Zlib: optimization, compression support

3. Install nginx

  • Upload to a folder
  • Run the tar ZXF command to decompress the compressed packageNginx – 1.12.2. Tar. Gz(According to the corresponding compressed package name)
  • Go to the decompressed file
  • /configure –prefix=/usr/local/nginx –with-http_ssl_module
  • Compile & install Run the make && make install command
  • Start the Nginx: / usr/local/Nginx/sbin/Nginx
  • View service netstat -lntp

If there are modified nginx configuration file, you can test by the following correct configuration file: / usr/local/nginx/sbin/nginx – t

Check the compiled module/usr/local/nginx/sbin/nginx – V

Note: Once the installation is complete, there will be four directories: conf configuration files, HTML web files, and the site root directory, similar to the htdocs directory in Apache. Logs Log file sbin Main binary program, startup program command

4. Nginx startup management

(1), execute the/usr/local/nginx/sbin/nginx file, complete start.

The "-c" parameter specifies the path to the configuration file. If you do not use the "-c" parameter, Nginx will load the nginx.conf file in the conf subdirectory of its installation directory by default.Copy the code

(2) Check whether the startup is successful

Lsof - I: 80 or netstat - tunpl | grep, 80;Copy the code

(3) Nginx management by viewing./nginx -h help command

Nginx Start nginx -s stop Stops the nginx service. Nginx -s reload Does not stop the Nginx service and reload the configuration file. Nginx -t checks whether the configuration file has errors.Copy the code