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 install and use Nginx virtual machine

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to install and use the Nginx virtual machine. It is very detailed and has a certain reference value. Friends who are interested must finish it!

Use multiple subdomains in the Nginx virtual machine, each to a different directory.

Such as:

Http {server {listen 80; server_name a.chenlb.com; access_log logs/a.access.log main; server_name_in_redirect off; location / {index index.html; root / home/www/host_a/;}} server {listen 80; server_name b.chenlb.com; access_log logs/b.access.log main; server_name_in_redirect off; location / {index index.html Root / home/www/host_b/;} http {server {listen 80; server_name a.chenlb.com; access_log logs/a.access.log main; server_name_in_redirect off; location / {index index.html; root / home/www/host_a/;}} server {listen 80; server_name b.chenlb.com; access_log logs/b.access.log main; server_name_in_redirect off Location / {index index.html; root / home/www/host_b/;}

It turns out that using b.chenlb.com still points to the host_a directory. Later, I looked at the official example: http://wiki.Nginx.org/NginxVirtualHostExample, and mentioned that there is a default match, such as:

Http {server {listen 80 default; server_name_; access_log logs/default.access.log main; server_name_in_redirect off; location / {index index.html; root / var/www/default/htdocs;} http {server {listen 80 default; server_name_; access_log logs/default.access.log main; server_name_in_redirect off; location / {index index.html; root / var/www/default/htdocs }

Add this default to make a.chenlb.com and b.chenlb.com work properly.

The above is all the contents of the article "how to install and use the Nginx virtual machine". Thank you for reading! Hope to share the content to help you, more related knowledge, 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

Development

Wechat

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

12
Report