CentOS 4.0 installation to configure the Nginx method

  • 2020-05-09 19:51:43
  • OfStack

1. Installation instructions:

System environment: CentOS-4.0

2. Dependent programs

      (1). gzip module requires zlib library
      (2). rewrite module requires pcre library
      (3). ssl support requires openssl library

3. There are two ways to install the dependent program: one is to download the package and the other is to install YUM once

(1) installation of zlib
      download address: http: / / zlib net/fossils /
          $tar -xvzf zlib-1.2.5.tar.gz
          $cd zlib-1.2.5.tar.gz
          $./configure
          $make
          $make install
(2) pcre installation
      download address: http: / / ftp exim. llorien. org/pcre /
          $tar -xvzf pcre-8.02.tar.gz
          $cd pcre-8.02
          $./configure --prefix=/usr/local/pcre --enable-utf8 --enable-unicode-properties
          $ make && make install
(3) openssl installation
      download address: http: / / mirrors ibiblio. org/openssl source /
          $tar zvxf openssl-1.0.0.tar.gz
          $cd openssl-1.0.0
          $./config --prefix=/usr/local/ssl-1.0.0 shared zlib-dynamic enable-camellia
          $make && make install

(4) installation of nginx

      download address: http: / / nginx org/download /
          $tar zvxf Nginx 0.8.40.tar.gz
          $cd Nginx 0.8.40
          $./configure
          $ make
          $ make install
        more configurations:
          ./configure --prefix=/usr/local/nginx
        -- with-openssl =/usr/include (ssl enabled)
        - with - pcre = / usr include pcre/(enable regular expressions)
        -- with-http_stub_status_module (install the program to view nginx status)
        -- with-http_memcached_module (memcache cache enabled)
        -- with-http_rewrite_module (enable support for url rewrite)
      method 2 is as follows: this method is good, it is not easy to make mistakes, if the network speed is 10 minutes faster can be completed, poor network speed can also be completed in 20 minutes.
      yum     yum     yum     yum yum
      now has three dependent programs installed successfully, following is the installation of Nginx 0.8.40.

          website to download address: http: / / www nginx. org /
          $tar zvxf Nginx 0.8.40.tar.gz
          $cd Nginx 0.8.40
          $./configure   // is installed under /usr/local/nginx by default
          $ make
          $ make install

4. Configuration (important)


    # Modify firewall configuration:
    [root@bogon nginx-0.8.4]# vi + /etc/sysconfig/iptables
    # Add configuration item
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    # Restart the firewall
    [root@bogon nginx-0.8.4]# service iptables restart

5. Start:


    # methods 1
    [root@bogon nginx-0.8.4]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    # methods 2
    [root@bogon nginx-0.8.4]# cd /usr/local/nginx/sbin
    [root@bogon sbin]# ./nginx

6. Stop:


    # The query nginx The main process,
    ps -ef | grep nginx
    # Stop the process
    kill -QUIT The main process,
    # A quick stop
    kill -TERM The main process,
    # Forced to stop
    pkill -9 nginx

7. Test:


    # Test port
    netstat � na|grep 80
    # Test in the browser
    http://127.0.0.1:80

8. Questions to note:
Solution to the problem when installing      :


    [root@bogon sbin]# ./nginx
    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
    [emerg]: still could not bind()     #netstat -nptl  // To view 80 The port has been used
    #killall nginx  // Can be


Related articles: