How to publish static resources in nginx

How to publish static resources in nginx

step

  • Place the prepared static resource files in the specified folder
  • Change the nginx configuration file: nginx.conf
  • Start the nginx service: start nginx (be sure to switch to the nginx directory)
  • Check whether the release is successful in the browser

Practical operation

Put the published static web pages into the specified folder:

insert image description here

Change the nginx configuration file:

insert image description here

The nginx.conf configuration content is as follows:

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
  worker_connections 1024;
}

http {
   gzip on;

  #Static file server {
    listen 8080;
    server_name localhost;

    location / {
      root D:/resources/statichtmls;
    }
  }

  #html file server {
    listen 8080;
    server_name 127.0.0.1 localhost;

    location / {
      root D:/resources/statichtmls;
      index index.html index.htm; 
    }
  }
}

Start nginx:

insert image description here

Check whether the release is successful

insert image description here

If it fails, please check the port number or other configurations, and whether the static file is correct.

Shutdown nginx

After the test is completed, if you do not use it, remember to close nginx

insert image description here

The next time I enter the system, I cannot log in, which means nginx is closed.

insert image description here

This is the end of this article about how to publish static resources with nginx. For more information about how to publish static resources with nginx, 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:
  • How to use nginx to access local static resources on Linux server
  • Detailed explanation of solving the problem of cross-domain access of nginx/apache static resources
  • Detailed explanation of Nginx + Tomcat to separate requests for dynamic data and static resources
  • Detailed explanation of simple configuration of nginx static resource server
  • Nginx implements reverse proxy example of static resources
  • Use nginx-http-concat module to merge static resource files in nginx

<<:  WeChat applet development form validation WxValidate usage

>>:  4 ways to avoid duplicate insertion of data in Mysql

Recommend

Design: A willful designer

<br />Years of professional art design educa...

Detailed explanation of the loop form item example in Vue

Sometimes we may encounter such a requirement, th...

How to set a fixed IP in Linux (tested and effective)

First, open the virtual machine Open xshell5 to c...

Detailed explanation of how to reduce memory usage in MySql

Preface By default, MySQL will initialize a large...

Use Navicate to connect to MySQL on Alibaba Cloud Server

1. First enter the server's mysql to modify p...

Detailed explanation of how to install MySQL on Alibaba Cloud

As a lightweight open source database, MySQL is w...

A brief discussion on group by in MySQL

Table of contents 1. Introduction 2. Prepare the ...

Shell script to monitor MySQL master-slave status

Share a Shell script under Linux to monitor the m...

Basic installation tutorial of mysql decompression package

Since I have changed to a new computer, all the e...

The principle and basic use of Vue.use() in Vue

Table of contents Preface 1. Understanding with e...

Node+express to achieve paging effect

This article shares the specific code of node+exp...