How to use nginx to build a static resource server

How to use nginx to build a static resource server

Taking Windows as an example, Linux is actually the same;

Build a static resource server

There are many pictures under the work folder on my computer. I want to build a static resource server through nginx and complete the directory mapping by entering the ip+port in the address bar.


Find the nginx installation directory, open the /conf/nginx.conf configuration file, and add a virtual host


Add listening port and access domain name

The key is to add location.

Mapping-URL: /work/;

Note: If there is already a location in the current server module and the URL is "/", then the URL of the newly created location should be the matching path and cannot be "/". At this time, the mapping path cannot be written casually. First, there must be this URL directory under your root directory, otherwise it will report 404 (this rule hurt me at the time);

If not, the URL can be written as "/", as shown below:


Add the root directory (the root directory where you want to display static resources, use forward slashes "/") between levels): D:/pic_resource/;

Enable browsing directory permission: autoinedx on, the default is off;

Then save and start nginx;

Nginx command under Windows: First, enter the nginx directory in cmd command mode,

Start: start nginx.exe;

Load the latest configuration: ./nginx.exe -s reload;

Stop: ./nginx.exe -s quit;

If you want to check whether it has been started, you can check whether there is an nginx.pid file in the logs file in the nginx directory. If there is, it means it has been started successfully.

If there is no error, you can check the error.log in the logs directory, which will remind you where the error occurred.

Enter 127.0.0.1:8008/work/ in the address bar, and you will see the following picture, indicating that the configuration is successful.


This is the end of this article about the steps to use nginx to build a static resource server. For more relevant nginx static resource server content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed tutorial on how to deploy Springboot project using Nginx on the server (jar package)
  • Detailed explanation of Nginx passively checking the server's survival status

<<:  Method example of safely getting deep objects of Object in Js

>>:  Summary of common knowledge points required for MySQL

Recommend

Detailed explanation of MySQL 8.0.18 commands

Open the folder C:\web\mysql-8.0.11 that you just...

Vue3 encapsulates the side navigation text skeleton effect component

Vue3 project encapsulation side navigation text s...

Docker data storage tmpfs mounts detailed explanation

Before reading this article, I hope you have a ba...

Detailed explanation of object literals in JS

Table of contents Preface 1. Set the prototype on...

How to completely uninstall node and npm on mac

npm uninstall sudo npm uninstall npm -g If you en...

Detailed explanation of the use of MySQL Online DDL

Table of contents text LOCK parameter ALGORITHM p...

Detailed explanation of TypeScript 2.0 marked union types

Table of contents Constructing payment methods us...

VMware Tools installation and configuration tutorial for Ubuntu

Some time ago, the blogger installed the Ubuntu s...

Example of implementing skeleton screen with Vue

Table of contents Skeleton screen use Vue archite...

How to use mysqldump to backup MySQL data

1. Introduction to mysqldump mysqldump is a logic...

Learn v-model and its modifiers in one article

Table of contents Preface Modifiers of v-model: l...

Detailed steps to install Sogou input method on Ubuntu 20.04

1. Install Fcitx input framework Related dependen...

The implementation principle of Mysql master-slave synchronization

1. What is MySQL master-slave synchronization? Wh...

Mysql stores tree structure through Adjacency List (adjacency list)

The following content introduces the process and ...