Linux installation steps nginx

If desired compilation tools installed on the system, the first and second step may be skipped, through installed yum list view

1, install compilation tools and libraries

  yum -y install make zlib zlib-devel gcc libtool  openssl openssl-devel

2, installation of PCRE, let NGINX support Rewrite feature

  yum install pcre

3, download and unzip the installation package

  // Create a folder

  cd /usr/local 

  Note:

  Non- root user can not create

   

  (If not need to configure --prefix when root privileges, create ./configure in the operational files plus) 

   

   

  

  cd /webapp/billing

  mkdir nginx

  cd nginx

  // download the tar package

  http://nginx.org/download/nginx-1.13.7.tar.gz wget (if not line installation, go to the official website to download the manual and uploaded to the server)

  tar -xvf nginx-1.13.7.tar.gz

4, install nginx

  // enter nginx directory

  cd /webapp/billing/nginx

  //Excuting an order

  ./configure --prefix=/webapp/billing/nginx(否则会默认编译到 /usr/local/ngnix 中,应用户为非 root 权限用户,导致 make install 时没有权限)

  //执行make命令

  make

  //执行make install命令

  make install

5、配置nginx.conf

  # 打开配置文件

  vi /webapp/billing/nginx/conf/nginx.conf

  #服务器集群

  upstream springbootNginx2 {

    server 134.32.51.64:28081 weight=10 max_fails=1  fail_timeout=30s;

    #server 134.32.51.64:28083 weight=10;

  }

 

     server {

          listen       8095;

          server_name  localhost;

          #charset koi8-r;

          #access_log  logs/host.access.log  main;

 

          location / {

              #root   html;

              #index  index.html index.htm;

     proxy_pass http://springbootNginx2;

          }

  

 

6、启动nginx启动后,可通过/webapp/billing/nginx/logs 中的 nginx.pid 查看端口号

  /webapp/billing/nginx/sbin/nginx

7、重启 nginx

  /webapp/billing/nginx/sbin/nginx -s reload

8、关闭 nginx

  ./nginx -s stop 关闭

Guess you like

Origin www.cnblogs.com/damong/p/11994215.html