In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The role of httpd virtual hosts: you can bind multiple sites to the same IP or multiple websites to multiple IP on the same host
Virtual hosts can be bound based on port or IP. Examples are as follows:
Www.a.com-- > 10.1.1.100 www.c.org 80 www.b.net-- > 10.1.1.100 www.c.org 808-- > 10.1.1.100 www.c.org 8080
Or
Www.a.com-- > 10.1.1.100 www.b.net-- > 10.1.1.101 www.c.org-- > 10.1.1.102
The above two can also be mixed, or multiple domain names can share an IP and port. In this case, multiple domain names need to be mapped to the same IP address on the dns.
Configure a virtual host (take CentOS 7 as an example):
Apache httpd profile:
Master profile:
/ etc/httpd/conf/httpd.conf / etc/httpd/conf.d/*conf # can also be used as part of the main configuration file
1. Installation service:
Yum-y install httpd
2. Back up the master configuration file and modify it to enable the virtual host later:
Vim / etc/httpd/conf/httpd.conf, comment out the default web page file path # DocumentRoot "/ var/www"-> httpd web page file default path
3. Find # ServerName www.example.com:80 and add the following:
After ServerName localhost:80 # is added, when the httpd service starts, it will not attempt to use the DNS server to resolve the native hostname.
4. Create a new virtual host configuration file in / etc/httpd/conf.d/ to facilitate subsequent management, and delete it when you don't need it.
Vim / etc/httpd/conf.d/vhosts.conf
4.1 if a port-based approach is used,
The port ServerName www.a.com DocumentRoot "/ www/a.com/htdocs/" # directory that needs to be enabled for Listen 808 # snooping is created in advance, and the index.html test files are placed in the corresponding directory ServerName www.b.net DocumentRoot "/ www/b.net/htdocs/"
4.2 if you use an IP-based approach, then
The ServerName www.a.com DocumentRoot "/ www/a.com/htdocs/" # directory is created in advance, and the index.html test files are placed in the corresponding directory ServerName www.b.net DocumentRoot "/ www/b.net/htdocs/".
4.3 if the FQDN method is used, then (this method mainly relies on the DNS server to bind multiple domain names to IP)
ServerName www.a.com DocumentRoot "/ www/a.com/htdocs/" ServerName www.a.com DocumentRoot "/ www/a.com/htdocs/"
Note: after modifying the configuration file of httpd, please use httpd-t to check the configuration file and restart the service again.
Possible problems and solutions
1. After the above configuration, the virtual host may be inaccessible. Please close SELinux and iptables.
SElinux shutdown method: setenforce 0 # temporarily shut down vim / etc/selinux/config # need to restart SELINUX=disabled SELinux View method: getenforce disable # is off loading CentOS 7 Firewall off method: systemctl disable firewalld.service
2. If you still cannot access it at this time, you will be prompted with a forbidden error that the path cannot be accessed, and add the following to the virtual host configuration file:
# refer to the configuration case for default path permissions in the main configuration file, where the path is the virtual host web page file path AllowOverride None # Allow open access: Require all granted
Note: access to web files is not allowed by default
After adding, httpd-t checks for syntax errors. If there is no problem, restart the service. At this time, the virtual host should be able to access it normally.
Server-status and identity authentication
1. If you need to obtain the server status through a virtual host and need to authenticate your identity, add the following:
ServerName www.a.comDocumentRoot "/ www/a.com/htdocs/" SetHandler server-status AuthType Basic AuthName "ENTER YOUR ID" AuthUserFile / etc/httpd/conf/.htpasswd # indicates the file path required for authentication Require valid-user # as long as the user exists, you can also specify the user name directly
2. Use htpasswd-c-m / etc/httpd/conf/.htpasswd USERNAME to create a user name and set a password
Note: the-c command is used only when the user is created for the first time, and the user generates a password file
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.