Prepare: First install some GCC libraries for compiling and some Nginx extension lib packages:
[Email protected] nginx-1.8. 1] # yum-y Install gcc gcc-c++ autoconf automake zlib zlib-devel OpenSSL openssl-devel pcre pcre-devel
1. First go to Nginx's official website to select the Nginx version to install and copy its downloaded URL, and in Linux with wget for download, tar decompression and access to the installed source directory:
[Email protected] ~]# wget-c http://nginx.org/download/nginx-1.8.1.tar.gz && tar zxvf. nginx-1.8.1.tar.gz && CD./nginx-1.8.1
Then look at the following major configuration options according to your own situation as well as the./configure--help command: Then configure one of the make three section./configure
[Email protected] nginx-1.8.1]# ./Configure>--prefix=/usr/local/Nginx>--sbin-path=/usr/local/nginx/sbin/ >--conf-path=/usr/local/nginx/conf/nginx.conf>--error-log-path=/var/log/nginx/Error.log>--pid-path=/var/run/nginx/Nginx.pid>--Lock-path=/var/Lock/nginx.Lock >--user=Nginx>--group=Nginx>--with-Http_ssl_module>--with-Http_flv_module>--with-Http_gzip_static_module>--http-log-path=/var/log/nginx/Access.log>--http-client-body-temp-path=/var/tmp/nginx/cilent/ >--http-proxy-temp-path=/var/tmp/nginx/proxy/ >--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
Some of the problems encountered:
Issue 1: (no GCC installed)
for 3.10. 0-327 for C compiler ... not found. is Not found resolved: [[email protected] nginx-1.8. 1] # yum-y Install gcc gcc-c++ autoconf automake
Issue 2: (some libraries are not installed because in./configure I use such as SSL, etc. to install according to your actual needs)
./using --without-fromusing --with-pcre=<path> option. Resolution: [ [Email protected] nginx-1.8. 1] # yum-y Install zlib zlib-devel OpenSSL openssl-devel pcre pcre-devel
OK next use make to try to compile under the detection of whether there is a problem (many times we are accustomed to making && made install directly into the build installation, it is because I have done the following test no problem in the building of the production environment in order to save time to do so)
[Email protected] nginx-1.8. 1] # make
If the word "error" is not present, make detection is fine. There are few errors when running make install.
[Email protected] nginx-1.8. 1] # make Install
OK to this has been installed complete:
This time I try to start under: (According to my./configure configuration Sbin-path is in/usr/local/nginx/sbin/nginx my default profile in/usr/local/nginx/conf/ nginx.conf)
[Email protected] nginx-1.8. 1] #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.confnginx: [Emerg] Getpwnam (" Nginx") failed
The above error indicates that I do not have nginx this user and master: two ways 1. Modify the user and group in nginx.conf to another user that already exists. It is not recommended to use ROOT;2. Create the user and group commands that I specified are as follows:
[Email protected] nginx-1.8. 1] #/usr/sbin/groupadd-F nginx[[email protected] nginx-1.8. 1]#/usr/sbin/useradd-g nginx
There are also error prompts when trying to start:
[Email protected] nginx-1.8. 1] #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/"/var/tmp/nginx/cilent/" failed (2: No such file or directory) [[email protected] nginx-1.8. 1]# mkdir/var/tmp/nginx/Cilentmkdir: Unable to create directory "/var/tmp/nginx/cilent ": Without that file or directory
Workaround creation:
[Email protected] nginx-1.8. 1] # Mkdir-p/var/tmp/nginx/cilent
Then start:
[Email protected] nginx-1.8. 1] #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
OK no error: Confirm whether start can be used Ps-ef | grep Nginx to retrieve (here is a technique, the general Nginx startup is this form, if your Linux server has a lot of nginx.conf This command can help you lock the current configuration file faster. )
[Email protected] nginx-1.8.1]# Ps-ef | grep nginxroot 42388 1 0 15:58? 00:00:00 nginx:master process/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.confnginx 42389 42388 0 15:58? 00:00:00 nginx:worker processroot 42391 10803 0 15:58 pts/1 00:00:00 grep--color=auto nginx
To explain the above parameters, the master process is the main one, and the PID is 42388. The following is the child process.
OK this process we can actually go to a file to see, yes we are in the./configure configuration of the PID file: Cat under this file will see that there is a corresponding PID number:
[Email protected] nginx-1.8.1]# cat/var/run/nginx/nginx.pid 42388
The function of this PID allows us to operate nginx and conveniently: such as restarting or stopping the service (kill) or smoothing the restart.
-QUIT '/var/run/nginx/-term '/var/run/nginx/9 '/var/run/ nginx/42388
[Nginx Learning Path]linux nginx Installation