In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Virtual Web host
Running multiple Web sites on the same server, each of which is not independent
Take up a real computer
Virtual host types supported by httpd
1. Virtual host based on domain name
two。 Virtual host based on IP address
3. Port-based virtual host
Example demonstrates domain name-based virtual hosting step 1: environment deployment
1. Install DNS software packages bind and httpd services for testing
[root@localhost] # yum install bind httpd-y...
two。 Provide domain name resolution for virtual hosts
[root@localhost ~] # vim / etc/named.conf / / enter the main configuration file options {listen-on port 53 {any;}; / / replace 127.0.0.1 with any. Allow-query {any;}; / / replace localhost with any [root@localhost ~] # vim / etc/named.rfc1912.zones / / enter the zone configuration file zone "accp.com" IN {/ / the first forward domain name type master; file "accp.com.zone" / / point to the zone data configuration file accp.com.zone allow-update {none;};}; zone "kgc.com" IN {/ / the second forward domain type master; file "kgc.com.zone" / / point to the zone data configuration file kgc.com.zone allow-update {none;};} [root@localhost ~] # cd / var/named/ enter the / var/named/ directory [root@localhost named] # cp-p named.localhost accp.com.zone / / copy the template file named.localhost is the accp.com.zone zone data configuration file [root@localhost named] # vim accp.com.zone / / edit area The domain data configuration file $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H; retry 1W; expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.235.129 / / add resolution A record and point to the host IP address [root@localhost named] # cp-p accp.com.zone kgc.com.zone / / copy the zone data configuration file where accp.com.zone is kgc.com.zone No need to modify [root@localhost named] # systemctl start named / / start the domain name resolution service [root@localhost named] # systemctl stop firewalld.service / / turn off the firewall [root@localhost named] # setenforce 0 / / turn off enhanced security step 2: use the client to test the DNS service
1. Modify the client's DNS server address to the address of the virtual host
two。 Open the client's cmd command prompt and use the nslookup command plus the domain name to obtain the resolved address
Step 3: set the configuration files related to the virtual host
1. Configure the configuration file for the virtual host
[root@localhost named] # cd / etc/httpd/conf / / enter the conf directory of the configuration file [root@localhost conf] # mkdir extra/ / create an extension directory [root@localhost conf] # cd extra/ enter the directory [root@localhost extra] # vim vhost.conf / / Edit the virtual host configuration file You can define / / label * all ip 80 port DocumentRoot "/ var/www/html/accp/" / / site directory ServerName www.accp.com / / site domain name ErrorLog "logs/www. Accp.com.error_log "/ / site error log file, logs is / var/log/httpd soft link (relative path) CustomLog" logs/www.accp.com.access_1og "common / / site access log / / control directory permissions Require all granted / / allow all access to DocumentRoot" / var/ www/ html/kgc/ "ServerName www. Kgc. ComErrorLog "logs/www.kgc.com.error_1og" CustomLog "logs/www.kgc.com.access_log" commonRequire all granted
two。 Configure web pages
[root@localhost extra] # cd / var/www/html/ enter the site directory [root@localhost html] # mkdir accp kgc [root@localhost html] # cd accp/ [root@localhost accp] # vim index.htmlthis is accp web [root@localhost accp] # cd.. / kgc/ [root@localhost kgc] # vim index.htmlthis is kgc web
3. Enter the httpd.conf configuration file and declare that it contains the previously created virtual host subprofile
[root@localhost kgc] # cd / etc/httpd/conf [root@localhost conf] # vim httpd.conf. Include conf/extra/vhost.conf / / access this entry at the last line to declare the inclusion of the virtual host subprofile [root@localhost extra] # systemctl start httpd/ / start the httpd service step 4: use the client to access the web
Port-based virtual host
1. Edit virtual host profile
[root@localhost extra] # vim vhost.conf... / / omit the previously configured part / / add port 8080 DocumentRoot "/ var/www/html/accp02" ServerName www.accp.comErrorLog "logs/www.accp02.com.error_log" CustomLog "logs/www.accp02.com.access_log" commonRequire all granted of the accp domain name
two。 Create a new web site with port 8080
[root@localhost extra] # cd / var/www/html/ [root@localhost html] # mkdir accp02 [root@localhost html] # cd accp02/ [root@localhost accp02] # vim index.htmlthis is accp02 test web
3. Modify the listening address of the httpd.conf configuration file
Vim / etc/httpd/conf/httpd.conf / / enter the configuration file... Listen 192.168.235.129 Listen 192.168.235.129 Listen 8080 / / find the Listen entry and add the 8080 port listening entry [root@localhost accp02] # systemctl restart httpd/ / restart the service
4. Use the client web page
Third, virtual host based on IP
1. First add the second network card, and then he will automatically get an IP address
two。 Configure the configuration file for the virtual host
[root@localhost accp02] # cd / etc/httpd/conf/extra/ [root@localhost extra] # lsvhost.conf [root@localhost extra] # vim vhost.conf 12 DocumentRoot "/ var/www/html/accp/" 3 ServerName www.accp.com 4 ErrorLog "logs/www.accp.com.error_log" 5 CustomLog "logs/www.accp.com.access_1og" common 6 7 Require all granted 8 9 10 11 12 DocumentRoot "/ var/www/html/accp02" 13 ServerName www. Accp.com 14 ErrorLog "logs/www.accp02.com.error_log" 15 CustomLog "logs/www.accp02.com.access_log" common 16 17 Require all granted 18 19
3. Modify the listening address of the httpd.conf configuration file
[root@localhost extra] # vim / etc/httpd/conf/httpd.conf... Listen 192.168.235.129:80Listen 192.168.235.142 IP 80 / / add another IP to listen [root@localhost extra] # systemctl restart httpd/ / restart the service
4. Use the client web page
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.