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

How to add virtual host function on Apache

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to add virtual host function on Apache related knowledge, detailed and easy to understand, simple and fast operation, has a certain reference value, I believe everyone read this article how to add virtual host function on Apache will have some gains, let's take a look at it.

Apache stores the root directory of web pages by default, which is below/var/www/html/, that is, by default, a server can only run one website. But a server with good performance, if only run a website, isn't it a bit wasteful? In fact, apache supports virtual host functions, and can run n websites in virtual host mode.

Apache enables virtual hosting in a very simple way. Take centos 6.3 and apache 2.2 as examples. Create a vhost.conf configuration file in/etc/httpd/conf.d/directory with the following format:

namevirtualhost *:80 servername aaa.com serveralias www.aaa.com documentroot /srv/www/aaa.com/public_html/ servername bbb.com serveralias www.bbb.com documentroot /srv/www/bbb.com/public_html/

Then create directories for both sites:

$ mkdir -p /srv/www/aaa.com/public_html$ mkdir -p /srv/www/bbb.com/public_html

Add an a record pointing to the IP address of the server in each of the above two domain names, and restart the apache server:

$ service httpd restart

If you need to record access logs and error logs, as well as to implement url rewriting and other functions, you need to make the following modifications:

serveradmin webmaster@aaa.com servername aaa.com serveralias www.aaa.com documentroot /srv/www/aaa.com/public_html/ errorlog /srv/www/aaa.com/logs/error.log customlog /srv/www/aaa.com/logs/access.log combined options followsymlinks allowoverride all order allow,deny allow from all About "how to add virtual host function on Apache" the content of this article is introduced here, thank you for reading! I believe that everyone has a certain understanding of "how to add virtual host function on Apache" knowledge. If you still want to learn more knowledge, please pay attention to 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.

Share To

Internet Technology

Wechat

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

12
Report