1. Install nginx from linux source

  1. Download the nginx.tar.gz source package from the official website
  2. Copy it to the Linux system for decompression tar -zxvf nginx.tar.gz
  3. To enter the decompressed directory, you need ./configure. This step will report multiple errors. For example, when gcc is not installed, it is required to install gcc, etc.
  • ./confiure

在./configure时,可能会报错,如下:./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.

  • The solution is to install the pcre-devel package, yum -y install pcre-devel in order to rewrite the rewrite
  • 安装了上面这个包后,还会报错,提示./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx 
  • At this point, you need to install the zlib-devel package, yum -y install zlib-devel for gzip compression

  4.make

  5.make install or a combination of 4 and 5, make && make install

  6. The programs installed by compiling will be saved in the /usr/local directory, as follows:

  • [root@localhost nginx-1.14.0]# ls /usr/local/nginx/
    conf html logs sbin
    [root@localhost nginx-1.14.0]#

  7. Run the command ./sbin/nginx to start nginx. You can view the process or port status through ps -ef | grep nginx or through netstat -anpl | grep 80

  • Visit firefox localhost:80, if the following interface appears, it means that nginx was started successfully:
  •  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324855647&siteId=291194637