CentOS system rpm installation and configuration of Nginx

CentOS system rpm installation and configuration of Nginx

CentOS rpm installation and configuration of Nginx

Official download address: http://nginx.org/en/download.html

introduce

Nginx ("engine x") is a high-performance Web and reverse proxy server developed by Russian programmer Igor Sysoev. It is also an IMAP/POP3/SMTP proxy server.

rpm package installation

#Install nginx, rpm installation#rpm install nginx package rpm -Uvh --force --nodeps nginx-1.16.1-1.el7.ngx.x86_64.rpm

#Check the startup status systemctl status nginx

The display is as follows:
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since 2021-11-26 11:12:41 CST; 5 days ago
     Docs: http://nginx.org/en/docs/
  Process: 1379 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 1543 (nginx)
    Tasks: 5
   CGroup: /system.slice/nginx.service
           ├─1543 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           ├─1544 nginx: worker process
           ├─1546 nginx: worker process
           ├─1547 nginx: worker process
           └─1548 nginx: worker process

November 26 11:12:41 liang systemd[1]: Starting nginx - high performance web server...
November 26 11:12:41 liang systemd[1]: Started nginx - high performance web server.

#Start systemctl start nginx

#Restart systemctl restart nginx

#Startup service systemctl enable nginx

#Check the boot status enabled: enabled, disabled: disabled systemctl is-enabled nginx

After installation, modify the /etc/nginx/conf.d/default.conf configuration file. The reference content is as follows:

vim /etc/nginx/conf.d/default.conf
server {
    listen 80;
    server_name localhost;

    #charset koi8-r;
    #access_log /var/log/nginx/host.access.log main;


     location /ui {
        alias /data/dist;
        index index.html index.htm;
     }
     
     location /file/ {
         root /home/data/;
        index index.html index.htm;
     }    
    # websocket configuration wss
    location /liangws/
        proxy_pass http://192.168.0.19:8080/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Remote_addr $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 600s;
    }

    location ~ /gat {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:18080 ;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    # proxy_pass http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #root html;
    # fastcgi_pass 127.0.0.1:9000;
    # fastcgi_index index.php;
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    #include fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    # deny all;
    #}
}

Note: Static file downloading depends on nginx. We need to put these files in the directory corresponding to /home/data/aaa in the nginx configuration file.

Start service configuration

cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

This is the end of this article about installing Nginx and configuring it with rpm on CentOS system. For more information about installing Nginx with rpm on CentOS, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Teach you how to quickly install Nginx in CentOS7
  • Detailed process of installing nginx1.9.1 on centos8
  • How to install Nginx in a specified location in Centos system

<<:  How to use resize to implement image switching preview function

>>:  Comparison of div and span in HTML_PowerNode Java Academy

Recommend

11 ways to remove duplicates from js arrays

In actual work or interviews, we often encounter ...

Tutorial on installing mysql8 on linux centos7

1. RPM version installation Check if there are ot...

Facebook's nearly perfect redesign of all Internet services

<br />Original source: http://www.a-xuan.cn/...

CSS3 creates 3D cube loading effects

Brief Description This is a CSS3 cool 3D cube pre...

How to install and connect Navicat in MySQL 8.0.20 and what to pay attention to

Things to note 1. First, you need to create a my....

Solution to find all child rows for a given parent row in MySQL

Preface Note: The test database version is MySQL ...

Introduction to the use of MySQL performance stress benchmark tool sysbench

Table of contents 1. Introduction to sysbench #Pr...

Use of js optional chaining operator

Preface The optional chaining operator (?.) allow...

Detailed tutorial on building a private Git server on Linux

1. Server setup The remote repository is actually...

A brief summary of all encapsulation methods in Vue

Table of contents 1. Encapsulation API 2. Registe...

Problems with installing mysql and mysql.sock under linux

Recently, I encountered many problems when instal...

Solution to forgetting mysql password under linux

The problem is as follows: I entered the command ...

Historical Linux image processing and repair solutions

The ECS cloud server created by the historical Li...

Five things a good user experience designer should do well (picture and text)

This article is translated from the blog Usability...

Web page image optimization tools and usage tips sharing

As a basic element of a web page, images are one ...