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

How to deploy Confluence and jira-software in Docker

version: centos==7.2 jdk==1.8 confluence==6.15.4 ...

Vue Element-ui form validation rule implementation

Table of contents 1. Introduction 2. Entry mode o...

CSS3 realizes the childhood paper airplane

Today we are going to make origami airplanes (the...

How to configure domestic sources in CentOS8 yum/dnf

CentOS 8 changed the software package installatio...

js realizes packaging multiple pictures into zip

Table of contents 1. Import files 2. HTML page 3....

Two ways to manage volumes in Docker

In the previous article, I introduced the basic k...

Use of Linux stat command

1. Command Introduction The stat command is used ...

Detailed explanation of the knowledge points of using TEXT/BLOB types in MySQL

1. The difference between TEXT and BLOB The only ...

Detailed analysis of MySQL instance crash cases

[Problem description] Our production environment ...

Implementation of the login page of Vue actual combat record

Table of contents 1. Preliminary preparation 1.1 ...

The easiest way to debug stored procedures in Mysql

A colleague once told me to use a temporary table...

CSS clear float clear:both example code

Today I will talk to you about clearing floats. B...

Teach you how to write maintainable JS code

Table of contents What is maintainable code? Code...