nginx service I Introduction and installation

Keywords: Nginx iptables firewall yum

1, nginx introduction

1.nginx service function:

  • a)web Services
  • b) Responsible for balancing
  • c)web cache

2. Advantages of nginx service:

  • a) Simple and flexible configuration
  • b) High concurrency (static small file)
  • c) Less resources
  • d) Various functions
  • e) Support epoll model
  • f) There are differences between matching dynamic services and Apache
  • g) Can limit the IP speed and the number of connections

2, nginx service web deployment

1. Installation Preparation

[root@nginx ~]# yum install openssl openssl-devel -y
[root@nginx ~]# yum install pcre pcre-devel -y
[root@nginx ~]# wget http://nginx.org/download/nginx-1.15.2.tar.gz
[root@nginx ~]# tar xf nginx-1.6.2.tar.gz 

2. Compile and install nginx

[root@nginx ~]# cd nginx-1.6.2
[root@nginx nginx-1.6.2]# useradd nginx -M -s /sbin/nologin
[root@nginx nginx-1.6.2]# ./configure --user=nginx --group=nginx \
--prefix=/usr/local/nginx-1.6.2 --with-http_stub_status_module --with-http_ssl_module
[root@nginx nginx-1.6.2]# make && make install
[root@nginx nginx-1.6.2]# mkdir /application
[root@nginx nginx-1.6.2]# ln -s /usr/local/nginx-1.6.2/ /application/nginx

3. Start nginx preparation

3.1 configure environment variables

[root@nginx nginx-1.6.2]# cd /application/nginx/
[root@nginx ~]# tail -1 /etc/profile
PATH=/application/nginx/sbin/:$PATH
[root@nginx ~]# source /etc/profile

3.2 check syntax

[root@nginx nginx]#nginx -t
nginx: the configuration file /usr/local/nginx-1.6.2/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.6.2/conf/nginx.conf test is successful

3.2 boot

[root@nginx nginx]#nginx 
[root@nginx nginx]# netstat -lntup|grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      4920/nginx

4. Turn off firewall, SE

[root@nginx nginx]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@nginx nginx]# setenforce 0

5. Web access

6. Deploy a site

6.1 modify the content of the first page

[root@nginx nginx]# cat html/index.html 
Welcome to https://blog.csdn.net/liang_operations

6.2 refresh web page

Posted by Edward on Wed, 08 Jan 2020 08:32:35 -0800