In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. What is a virtual host
Virtual hosts use special technology to logically divide a running server into multiple hosts. The main reason for this is to allow multiple website programs to run on a physical server, so that you can take advantage of the remaining space on the server. Give full play to the role of the server. Virtual hosts are completely independent.
In this way, when you use nginx to build a website platform, you only need to use one nginx software to run multiple ip-based or domain name-based websites.
2. Virtual host based on domain name
This domain name-based virtual host is the most commonly used. Ip-based ones are generally used in the intranet.
(1) configuration in nginx.conf
Just add the following fields to the nginx.conf.
Include vhosts/*.conf
The above fields can be added to the http module.
Then create the vhosts directory in the conf directory of nginx, but do not create it if you have one.
(2) add virtual host configuration file
Add a clear .conf configuration file to the vhosts directory with any name, preferably related to the deployed application, for later maintenance.
Take the previous configuration as an example
Server {listen 80; # configure the listening port, as long as configure 80, no matter how many virtual hosts are written, use port 80 server_name ebook.yunweigonghui.com; # this is the most important, configure the required domain name. It is also important that root / usr/local/ywgh/nginx/html/wp/; # write down the project path clearly, and don't misconfigure it. The access_log / usr/local/ywgh/nginx/logs/wp/access.log main; # access log can be written clearly or not. In the production environment, the log must be configured clearly to separate the log. Location ~\ .php$ {try_files $uri = 404; fastcgi_pass 127.0.0.1 uri 9000; error_log / usr/local/ywgh/nginx/logs/wp/php-error.log; include fastcgi.conf; fastcgi_index index.php;} # is about the configuration of php. }
After the above configuration, restart nginx or reload.
(3) Summary
Many virtual hosts can be written in the same configuration file, but it will be inconvenient to maintain at a later stage (the author has a lot of experience, especially when connecting to platforms maintained by others). Write as many configuration files as possible so that they look short and easy to read.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.