Linux, nginx deployment

A, nginx basic operation

1, the installation: yum install nginx

    (1) add resources: sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

    (2) start the download installation: sudo yum install -y nginx

2, start: service nginx start

    (1) View process: ps -ef | grep nginx

3, stop: service nginx stop

4, overloading: service nginx reload (important when using nginx configuration modification does not affect the operation of the line item)

Note: Enter the installation path: Under cd / etc / nginx, you can view profiles

            View network processes: sudo netstat -anpl | grep "nginx"

2906640-2581d286169759fb.png

Viewing the Access Log: sudo tail -f /var/log/nginx/access.log





Two, Nginx expand knowledge

1, Web Hosting

Enter: sudo vim /etc/nginx/conf.d/ttt.conf

Ttt.conf configuration file, but you need to be modified in the machine: sudo vim / etc / hosts file, add the virtual domain names ip is mapped ~~~

Native:


2906640-d813f950062e97ca.png

The configuration file on the server:

2906640-bb830adf9212961b.png


2, multi-domain, multi-port

Listen for a plurality of listening ports in the configuration file as shown above! ! !


3, pseudo-static

In the configuration file, add:

location / {

        rewrite ^(.*)\.htmp$ /index.html;

}

Those who visit htmp suffix are index.html


4, the log format

First, view the log: sudo tail -f /var/log/nginx/access.log

View Profile: sudo vim /etc/nginx/nginx.conf


2906640-77ac3e7c5a0debea.png


In the configuration file to customize the log in ttt.conf


2906640-874a6582e1bb1a4e.png

Use: tail -f / var / log / nginx / tail -f access_test.log view the output log! ! !







5, reverse proxy and load balancing

Reverse Proxy:


2906640-c2802eec6312fab9.png

Load Balancing:


2906640-2dc5b2974d77530f.png



6, debugging techniques


7, see the nginx state, the reality out wrong information

sudo systemctl status nginx.service

Reproduced in: https: //www.jianshu.com/p/6c037759c533

Guess you like

Origin blog.csdn.net/weixin_33757609/article/details/91333446