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

Robots.txt detailed introduction

Basic introduction to robots.txt Robots.txt is a p...

Skin change solution based on Vue combined with ElementUI

Table of contents Written in front Solution 1: Us...

Analysis of parameter transfer process of driver module in Linux

Declare the parameter name, type and permission y...

Nginx reverse proxy to go-fastdfs case explanation

background go-fastdfs is a distributed file syste...

mysql method to recursively search for all child nodes of a menu node

background There is a requirement in the project ...

Usage of if judgment in HTML

In the process of Django web development, when wr...

We're driving IE6 to extinction on our own

In fact, we wonder every day when IE6 will really...

Solve the error problem caused by modifying mysql data_dir

Today, I set up a newly purchased Alibaba Cloud E...

Steps to repair grub.cfg file corruption in Linux system

Table of contents 1. Introduction to grub.cfg fil...

Best Practices for Sharing React Code

When any project develops to a certain complexity...

Detailed explanation of Tomcat's commonly used filters

Table of contents 1. Cross-domain filter CorsFilt...

An example of implementing a simple infinite loop scrolling animation in Vue

This article mainly introduces an example of Vue ...

10 Deadly Semantic Mistakes in Web Typography

<br />This is from the content of Web front-...

Difference between varchar and char types in MySQL

Table of contents aforementioned VARCHAR Type VAR...

How to manually upgrade the kernel in deepin linux

deepin and Ubuntu are both distributions based on...