In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of Linux how to configure the virtual host, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to configure the virtual host in Linux. Let's take a look.
Virtual host introduction: virtual host (Virtual Host) is a network technology that allows multiple host names to operate on a single server, and each single host name can be supported separately.
Detailed steps for Linux system configuration of virtual hosts: multi-site configuration based on domain name (host name) configures two sites on one host. The domain names are asteria-222.localdomain and west.example.com, and the corresponding site files are stored in / var/www/html and / var/www/west.
First, we need to install the httpd service (yum install-y httpd) and make it work (the default port is 80 and the accessed html file is index.html). At this point, we can normally visit the website (index.html) under the default release directory (/ var/www/html) through the browser.
The configuration file for the httpd service is in the directory: / etc/httpd/conf.d, but there is no configuration file for the virtual host. At this point, we can use the rpm-qd httpd command to view the relevant configuration file and copy it to that directory. For example, vim vhosts.conf is entered in command mode
You can copy the file you need, and we can see that it is about the configuration of the virtual host, and at the end of the file, there is a template for how to write the configuration file:
You can simply write it as: (line 1 is followed by the port number; line 2 is the file directory, which is the default publishing directory for the host; line 3 ServerName refers to the name of the host)
Write the information of the virtual host we want to configure according to the template, as shown in the following figure:
At this time, we have configured the relevant files, but since the domain name may not be resolved by the machine when accessing the domain name, we need to configure the local hosts to resolve the domain name. Add the following two items to the configuration file / etc/host to parse 172.25.254.222 asteria-222.localdomain172.25.254.222 west.example.com
Finally, restart the httpd service (systenctl restart httpd.service) and access the domain name separately in the browser.
Above, we learned how to configure virtual hosts, but with regard to these sites, when the network is connected, anyone can directly access them, but sometimes we don't want others to see them. We can configure that only authenticated users can access them. Here's a simple configuration to allow only your own access: first, create a new web page in the directory / var/www/html/linux, and then anyone can access it.
Similarly, at the end of the configuration file / etc/httpd/conf.d/vhosts.conf, add:
Allow indicates the whitelist, and deny indicates that the four addresses allowed to be accessed by the blacklist represent their own computers.
At this time, we are using other hosts to visit this site, so we can't visit it successfully.
This is the end of the article on "how to configure virtual hosts for Linux". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to configure virtual hosts in Linux". If you want to learn more, 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.