Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to bind domain name and set root directory for nginx server

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article Xiaobian introduces in detail "how to bind the domain name and set the root directory on the nginx server", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to bind the domain name and set the root directory on the nginx server" can help you solve your doubts.

It is very convenient for the nginx server to bind the domain name and set the root directory. First, enter the nginx installation directory, then execute vim conf/nginx.conf to open the configuration file of nginx, and find the

Server {..}

This code segment, this code is used to configure the corresponding site. First of all, we should resolve the domain name to the ip address of our server in the domain name control panel before the binding can take effect.

First of all, find the item server_name in our code snippet, and then change the following domain name to the domain name we want to bind.

Root is the specified root directory, which can be set to the directory we specify.

What if we want to bind multiple domain names, or various secondary domain names, such as hao., tools. Such a secondary domain name First of all, resolve the domain name to the server, and then copy the above server {} code snippet and paste it again and again below. In this way, constructing multiple server is a multi-site configuration. Be careful to copy it all, the curly braces must be symmetrical, and there must be a space or line break between the curly braces and the previous statement in the shell script. This is very important, such as server {or if () {, etc., other things are easy to understand. Of course, many integration packages will set up a directory of code virtual hosts such as vhost in the same directory as the configuration file nginx.conf, set multiple configuration files for binding multiple domain names, such as aa.conf and bb.conf files, and then use include vhost/*.conf in nginx.conf All introduction, introduction is equivalent to all code written in nginx.conf, and do not consider the relationship of other directories, are subject to nginx.conf, so it is easy to manage, such as aa.conf

Other rule configurations can also be managed by establishing multiple files as above, save and exit after all configuration, and then restart the server to take effect.

In addition, listen specifies the site port, and you can customize the configuration without conflict. It is enough for server_name to specify the domain name, index to specify the default home page, and root to specify the root directory, so that you can master the basic configuration.

After reading this, the article "how to bind a domain name and set up a root directory on a nginx server" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about related articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report