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

Building a virtual host with Apache

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

1. Virtual Web host

Running multiple Web sites on the same physical server, each of which is not independently occupied-a real computer

II. Types of virtual hosts supported by httped

Virtual host based on domain name

Virtual host based on IP address (double network card, multiple network card, multiple IP address). Do not recommend, it will cost more to apply for public network IP)

Port-based virtual host (different ports, visit different websites)

Third, build a virtual host

Based on domain name:

1. A. Provide domain name resolution for virtual hosts. First configure the main configuration file

[root@localhost conf] # vim / etc/named.conf options {listen-on port 53 {any;}; / / modify the listening address listen-on-v6 port 53 {:: 1;}; directory "/ var/named"; dump-file "/ var/named/data/cache_dump.db"; statistics-file "/ var/named/data/named_stats.txt" Memstatistics-file "/ var/named/data/named_mem_stats.txt"; recursing-file "/ var/named/data/named.recursing"; secroots-file "/ var/named/data/named.secroots"; allow-query {any;}; / / allowed range

B. Configure the area configuration file

[root@localhost conf] # vim / etc/named.rfc1912.zones zone "kgc.com" IN {type master; file "kgc.com.zone"; allow-update {none;};}; zone "accp.com" IN {type master; file "accp.com.zone"; allow-update {none;}

C. Configure the area data configuration file

[root@localhost conf] # cp-p named.localhost accp.com.zone root@localhost conf] # vim accp.com.zone [root@localhost conf] # cp-p named.localhost kgc.com.zone [root@localhost conf] # vim kgc.com.zone

2. A, add virtual host configuration

[root@localhost conf] # cd / etc/httpd / / enter the httpd system configuration file [root@localhost httpd] # lsconf conf.d conf.modules.d logs modules run [root@localhost httpd] # cd conf [root@localhost conf] # lshttpd.conf magic [root@localhost conf] # mkdir extra/ / create a directory under the conf directory [root@localhost conf] # lsextra httpd.conf magic [root@localhost conf] # cd extra/ [root@localhost extra] # vim vhost.conf / / add virtual host configuration to the new directory

B. Configure website information and specify the configuration path of virtual host domain name.

[root@localhost httpd] # cd / var/www/html/ [root@localhost html] # ls [root@localhost html] # mkdir accp kgc/ / create directory [root@localhost html] # lsaccp kgc [root@localhost html] # cd accp/ [root@localhost accp] # ls [root@localhost accp] # vim index.html / / configure website information [root@localhost accp] # cd.. / [root@localhost html] # cd kgc/ [root@localhost Kgc] # vim index.html [root@localhost kgc] # cd / etc/httpd/ [root@localhost httpd] # lsconf conf.d conf.modules.d logs modules run [root@localhost httpd] # cd conf [root@localhost conf] # lsextra httpd.conf magic [root@localhost conf] # vim httpd.conf / / specify the profile path [root@localhost conf] # systemctl start httpd/ / start the httpd service. Failed to start the service Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl-xe" for details. [root@localhost conf] # cd extra/ [root@localhost extra] # vim vhost.conf / / add the common command [root@localhost extra] # systemctl start httpd / / to the configuration file to start the httpd service

3. Log in to win10 to view the experimental results

Second, based on IP. Configure add virtual host port information, create new directory, configure website information, modify listening port number

1. Add a network card and set up a double network card.

[root@localhost extra] # vim vhost.conf configuration Virtual Host IP [root@localhost extra] # cd / var/www/html [root@localhost html] # lsaccp kgc kgc02 [root@localhost html] # mkdir accp02 create a new directory under / var/www/html Add edit website information [root@localhost html] # cd accp02/ [root@localhost accp02] # vim index.html [root@localhost accp02] # vim / etc/httpd/conf/httpd.conf modify listening IP port number

The regional data configuration file should also be mapped accordingly.

Third, based on the port (take www.kgc.com as an example), configure to add virtual host port information, create a new directory, configure website information, and modify the listening port number

[root@localhost extra] # vim vhost.conf configuration virtual host configuration file [root@localhost extra] # cd / var/www/html/ [root@localhost html] # lsaccp kgc [root@localhost html] # mkdir kgc02/ / create a new kgc02 directory [root@localhost html] # lsaccp kgc kgc02 [root@localhost html] # cd kgc02/ [root@localhost kgc02] # vim index.html / / configure website information

2. Configure the listening port number

[root@localhost kgc02] # vim / etc/httpd/conf/httpd.conf [root@localhost kgc02] # systemctl restart httpd restart httpd service

3. Log in to win10 to view the experimental results

All the three ways of building virtual hosts by apache are introduced. I will check more practical information points on my home 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.

Share To

Network Security

Wechat

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

12
Report