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

Gearman + MySQL to achieve persistence operation example

This article uses the gearman+mysql method to imp...

Detailed explanation of MySQL multi-table join query

Table of contents Multi-table join query Inner Jo...

HTML sample code for implementing tab switching

Tab switching is also a common technology in proj...

MySQL and MySQL Workbench Installation Tutorial under Ubuntu

Ubuntu install jdk: [link] Install Eclipse on Ubu...

VMware12 installs Ubuntu19.04 desktop version (installation tutorial)

1. Experimental description In the virtual machin...

Implementation of MySQL scheduled backup script under Windows

On a Windows server, if you want to back up datab...

Detailed explanation of asynchronous iterators in nodejs

Table of contents Preface What are asynchronous i...

The difference between absolute path and relative path in web page creation

1. Absolute path First of all, on the local compu...

OpenSSL implements two-way authentication tutorial (with server and client code)

1. Background 1.1 Problems A recent product testi...

Why do select @@session.tx_read_only appear in DB in large quantities?

Find the problem When retrieving the top SQL stat...

Centos8 bridge static IP configuration method in VMware virtual machine

1. Make sure the network connection method is bri...

Detailed explanation of the core concepts and basic usage of Vuex

Table of contents introduce start Install ① Direc...

HeidiSQL tool to export and import MySQL data

Sometimes, in order to facilitate the export and ...

Introduction to Nginx regular expression related parameters and rules

Preface Recently, I have been helping clients con...