“This is the 12th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

01. Introduction to nginx software

1) High concurrent performance (memory) free-m

2) Powerful

A. Implement the Web service function == Apache b. Implement the cache function c. Implements load balancingCopy the code

02. Nginx Web service software deployment process

    1Nginx install nginx install nginx install nginxinit.d/nginx restart
	
	2Compilation and installation can customize some special functionsCopy the code
Nginx deployment processCopy the code
First mileage: download rely on yum install - y pcre - devel openssl devel RPM - qa | grep pcre view RPM - qa | grep openssl second mileage: Download nginx software mkdir /server/tools CD /server/tools/ wget HTTP:/ / nginx.org/download/nginx-1.14.0.tar.gzThe third milestone: the worker process is managed by the specified user -- WWW useradd www-m-s /sbin/nologin id WWW useradd www-m-s /sbin/nologin id WWW useradd www-m-s /sbin/nologin id1.14. 0.tar.gz Decompressing operationsCopy the code
Configure --prefix=/application/nginx-1.14 --user=user= WWW --group= WWW. Configure --prefix=/application/nginx-1.14 --user=user= WWW --group= WWW --with-http_ssl_module --with-http_stub_status_module --prefix=PATH set installation prefix Sets installation PATH information --user= user set Set non-privileged user for worker processes. --group= group set non-privileged group for worker processes --with-http_ssl_module enable ngx_http_SSL_module Enable SSL --with-http_stub_status_module enable Ngx_http_stub_status_module starts the module that monitors nginx status. 2) compile process make 3) compile installation process make install 2) and 3) execute make && make install together [root @ web01 nginx - 1.14.0] # echo $? Log -s /application/nginx-1.14/ /application/nginx-1.14/ /application/nginx 01 Directory structure of the nginx program conf ---- Directory for saving configuration files (nginx.conf) HTML ---- Site directory, Log ---- log file (error log file Access log file pid file) sbin ---- program command save file Start nginx service nginx (it is recommended to set environment variables) Stop nginx service nginx -s stop Smooth restart nginx -s reload check nginx configuration file syntax nginx -tCopy the code

02. Take a closer look at the nginx configuration file contents

CD /application/nginx [root@web01 conf]# grep -Ev "^$|#" nginx.conf.default >nginx.conf
   [root@web01 conf]# cat nginx.conf
   	
   worker_processes  1;
   events {
       worker_connections  1024;
   }
   http {
       include       mime.types;
       default_type  application/octet-stream;
       sendfile        on;
       keepalive_timeout  65;
       server {
           listen       80;
           server_name  localhost;
           location / {
               root   html;
               index  index.html index.htm;
           }
           error_page   500 502 503 504  /50x.html;
           location = /50x.html { root html; }}}Copy the code

Nginx configuration file specification summary: 1) configuration file instructions or parameters, must be written correctly (spelling position) 2) each block is a pair of curly braces 3) all block instructions in the end should have a good point

03. Configure the virtual host information

Write virtual host website page code file root@web01 HTML]# vim fuboyu.html site directory writtenWebsite login input10.0. 07./fuboyu.html
   
   <html>
   <meta charset="utf-8"> <head> <title> Ollie to </title> </head> <body> flush! <table border=1>
   <tr><td>01</td><td></td></tr>
   <tr><td>02</td><td></td></tr>
   <tr><td>03</td><td></td></tr>
   </table>
   <a href="http://baidu.com">
   <img src="stu.png"/>
   </a>
   </body>
   <html>
Copy the code

Write multiple virtual host methods: the first mile: write configuration files

[root@web01 conf]# vim nginx.conf
[root@web01 conf]# cat nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name www.etiantian.org;        
            root   html/www;
            index  index.html index.htm;
        }
    server {
        listen       80;
        server_name bbs.etiantian.org;        
            root   html/bbs;
            index  index.html index.htm;
        }
    server {
        listen       80; server_name blog.etiantian.org; root html/blog; index index.html index.htm; }}Copy the code

The second mile creates the site directory

mkdir /application/nginx/html/{www.bbs.blog}
Copy the code