Linux Nginx installation details, Linux Nginx Installation Details
This article is personal originality and will be updated in real time in the future based on the project practice. If it is reproduced, please indicate the source for your convenience to get the latest blog! Note: Install Nginx requires that openssl-fips-2.0.2.tar.gzzlib-1.2.7.tar.gzpcre-8.21.tar.gz has been installed in LinuxStep 1:Download the corresponding version from http://nginx.org/download/( or wget http://nginx.org/download/nginx-1.9.tar.gzdirectly on linux)Step 2:Decompress tar xzf nginx-1.9.9.tar.gzStep 3:Set the configuration information. /configure -- prefix =/customize the installation directory, or do not execute this step, directly default configuration (note: -- prefix =/usr/local/nginx indicates to install nginx in the/usr/local/nginx directory. If the installation directory is not specified, installed in the/urs/local/nginx directory by default. This example is installed in the default installation path)Step 4:Make compilation (The make process is to convert source code files written in various languages into executable files and various library files) make install (make install copies the compiled executable files and library files to appropriate places) Step 3: handle errors: If the oppenssl and pcre installation packages are not installed, the following error occurs in step 3.Error 1 :. /configure: error: the HTTP rewrite module requires the PCRE library. solution: install pcre-develyum-y install pcre-devel. Error 2 :. /configure: error: the HTTP cache module requires md5 functions
From OpenSSL library. You can either disable the module by using
-- Without-http-cache option, or install the OpenSSL library into the system,
Or build the OpenSSL library statically from the source with nginx by using -- with-http_ssl_module -- with-openssl = <path> options. solution: install opensslyum-y install openssl-devel after the preceding four steps, nginx has been installed.(1) check whether the installation is successful[Root @ localhost nginx-1.2.6] # cd/usr/local/nginx/sbin [root @ localhost sbin] #./nginx-t displays the following prompt, indicating that the installation is successful
(2) Start nginx
[Root @ localhost sbin] #./nginx
(3) Stop the operationThe stop operation sends a signal to the nginx process (see the linux chapter for the signal). Step 1: query the nginx master process number.
Ps-ef | grep nginx looks for the master process in the process list. Its number is the master process number. Step 2: send signals
Stop Nginx with ease:
Kill-QUIT master process number
Stop Nginx quickly:
Kill-TERM master process number
Force stop Nginx: pkill-9 nginx. if the pid file storage path is configured in conf, the file stores the Nginx main process number. If no pid file is specified, the file is stored in the nginx logs directory. With the pid file, we do not need to first query the main process Number of Nginx, but directly send a signal to Nginx. The command is as follows: kill-signal type '/usr/nginx/logs/nginx. pid'
Smooth restart
If you change the configuration, restart Nginx. Do you need to disable Nginx before enabling Nginx? No. You can send a signal to Nginx to restart Nginx smoothly.
Smooth restart command: use kill-HUP to enter the file path of the title or process number, or use/usr/nginx/sbin/nginx-s reload. Note, after modifying the configuration file, you 'd better check whether the modified configuration file is correct to avoid Nginx errors affecting the stable running of the server. The command to determine whether the Nginx configuration is correct is as follows:
Nginx-t-c/usr/nginx/conf/nginx. conf
Or
/Usr/nginx/sbin/nginx-t