Nginx installation and configuration detailed tutorial

Nginx

nginx is a high-performance HTTP and reverse proxy server. Asynchronous non-blocking I/O and capable of high concurrency.

  1. Forward proxy: The client is the proxy, and the server does not know who the client is.
  2. Reverse proxy: The server acts as a proxy and the client does not know who the server is.

Common commands

测试:nginx -t
启动:nginx
重启:nginx -s reload
停止:nginx -s stop

View system kernel information

[root@iZ8vba8362n915w3kubg90Z /]# cat /proc/version
Linux version 4.18.0-193.28.1.el8_2.x86_64 ([email protected]) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Thu Oct 22 00:20:22 UTC 2020

Installation configuration

  1. Add the nginx repo
    and check whether there is an nginx.repo file in the /etc/yum.repos.d/ directory.
  • If so, enter the current directory and enter: vim nginx.repoedit
  • If not, increase it touch nginx.repoand repeat the above steps.
    Enter the following:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
  1. :wqAfter saving, use yum updateas follows:
    Insert image description here

  2. Execute yum install -y nginxto install, nginx -vcheck the version
    Insert image description here

  3. Execute nginxthe startup process, and then execute ps -ef | grep nginxto view the process startup status
    Insert image description here

  4. The installed nginx
    accesses the current server in the directory /etc/nginx, and the following interface will appear (stored in the /usr/share/nginx/html directory)
    Insert image description here

  5. Enter /etc/nginx to execute vim nginx.confand configure the project (under /home/dist). The configuration content is as follows:

    server {
        listen 8000;
        server_name _;
        root /home/dist;
        location / {
        }
        error_page 404 /404.html;
        location = /40x.html {}
    }

:wqAfter saving, nginx -s reloadrestart nginx, and then access the server IP address and port. The project interface will appear, indicating that the configuration is successful.
Insert image description here

If the access is unsuccessful, check whether the port access permission is enabled in the cloud server management background.
Insert image description here

Summarize

The above is a detailed tutorial on Nginx online installation introduced by the editor to you. I hope it will be helpful to you!

Guess you like

Origin blog.csdn.net/kiscon/article/details/115056537