Nginx install and run

Nginx install and run

Install Nginx

  1. In Nginx official website to download the corresponding nginx package (recommended Stable [Stable version])

  2. Upload nginx package to the Linux system

  3. Installation depends Environment

    1. Install gcc environment

      yum install gcc-c++

    2. Install PCRE library for parsing regular expressions

      yum install - y pcre pcre-devel

    3. Install zlib compression and decompression dependence

      yum install -y zlib zlib-devel

    4. Installation secure SSL Secure Sockets Layer, HTTP for secure transmission, i.e. https

      yum install -y openssl openssl-devel

  4. Nginx unzip the package, after decompression is nginx source, the need to install after compiling

    tar -zxvf nginx-1.16.1.tar.gz

  5. Before compiling, first create a temporary directory nginx, if not created, the process will start nginx error

    mkdir /var/temp/nginx -p

  6. After the files are decompressed nginx directory, enter the following command is executed, the purpose is to create the makefile

    ./configure \
    --prefix=/usr/local/nginx \
    --pid-path=/var/run/nginx/nginx.pid \
    --lock-path=/var/lock/nginx.lock \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --with-http_gzip_static_module \
    --http-client-body-temp-path=/var/temp/nginx/client \
    --http-proxy-temp-path=/var/temp/nginx/proxy \
    --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
    --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
    --http-scgi-temp-path=/var/temp/nginx/scgi
    • NOTE: \ represents the command line wrap for readability

    • Configuration command:

      command Explanation
      --prefix Specifies the installation directory nginx
      –pid-path The point pid nginx
      –lock-path Lock installation files to prevent malicious tampering or misuse
      –error-log Error Log
      –http-log-path http log
      –with-http_gzip_static_module Enable gzip module, online real-time compression output data stream
      –http-client-body-temp-path Set temporary directory client requests
      –http-proxy-temp-path Http proxy set temporary directory
      –http-fastcgi-temp-path Set temporary directory fastcgi
      –http-uwsgi-temp-path Uwsgi set temporary directory
      –http-scgi-temp-path Set temporary directory scgi
  7. make compilation

    make

  8. installation

    make install

  9. Into the sbin directory to start nginx

    ./nginx

    • stop:./nginx -s stop
    • Reload the configuration:./nginx -s reload

run

Open a browser to access the host ip address to open the nginx default page, shown below would indicate a successful installation:

Nginx

Precautions

  1. If the cloud server installation, you need to open the default port nginx: 80
  2. If you install in a virtual machine, you need to turn off the firewall
  3. Local win or mac need to turn off the firewall

Guess you like

Origin www.cnblogs.com/supergan/p/12070710.html