SoFunction
Updated on 2025-03-09

Linux installation and configuration method

Install Nginx and configuration of Linux

Operation as follows

**Install the above four dependencies with one click**
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel   

**Create a folder**
cd /usr/local
mkdir nginx
cd nginx

**downloadtarBag**
wget /download/nginx-1.13.

**Decompressiontar**
tar -xvf nginx-1.13.

**EnternginxTable of contents**
cd /usr/local/nginx

**EnterTable of contents**
cd nginx-1.13.7

**Execute the command Considering subsequent installationsslCertificate Add two modules**
./configure --with-http_stub_status_module --with-http_ssl_module

**implementmakeOrder**
make

**implementmake installOrder**
make install

**start upnginxServe**
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/

**Open the configuration file**
vi /usr/local/nginx/conf/   

*
*Configuration below
*


**After configuration Restartnginx**
/usr/local/nginx/sbin/nginx -s reload

**You can take a lookNginx是否start up**
ps -ef | grep nginx

###Related Commands安装完成一般常用Order

Enter安装Table of contents中,

Order: cd /usr/local/nginx/sbin

start up,closure,Restart,Order:

./nginx start up

./nginx -s stop closure

./nginx -s reload Restart

Pay attention to the following text description

#The first step changes this to rootuser root;
worker_processes  1;

#error_log  logs/;
#error_log  logs/  notice;
#error_log  logs/  info;

#pid        logs/;


events {
    worker_connections  1024;
}


http {
    include       ;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/  main;

        #vue project packaged dist itself in front-end project location        root         /www/jinghui/dist/;
        location /{
                   try_files $uri $uri/ @router;# Need to point to the @router below, otherwise the route of vue will appear refreshed in nginx and appears 404                   index   ;
               }

        #Complied with @router above, the main reason is that the routed path resource is not a real path, so the specific file cannot be found        # Therefore, you need to rewrite it and then hand it over to the route to process the request resource        location @router {
                   rewrite ^.*$ / last;
        }

	 # /api: is the prefix from proxy to backend     location /api {
     		#Fill in the direct intranet IP address            proxy_pass http://*.*.*.*:9001/;
            #proxy_pass http://&env;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header REMOTE-PORT $remote_port;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            rewrite ^/api/(.*) /$1 break;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }


        #nacos configuration        location /nacos/ {
            rewrite  ^//(.*)$ /$1 break;
            #Fill in your intranet IP address            proxy_pass http://*.*.*.*:8080/nacos;
            proxy_set_header Host $host;
            proxy_set_header User-Agent $http_user_agent;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header authorization $http_authorization;
        }
        #error_page  404              /;

        # redirect server error pages to the static page /
        #
        error_page   500 502 503 504  /;
        location = / {
            root   html;
        }
    }
}

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.