Apache Virtual Host build (single IP multi-site server configuration)

Source: Internet
Author: User

Some small sites if a Web site on a server will be a huge waste of server resources, how to set up multiple sites on a server?

We already know, set up a website need HTTP service, after installing Apache, we can put the content of our website into/usr/local/apache2/htdocs/inside, start httpd service, install firewall, can browse our website, So what do you do if you want to deploy multiple sites? This requires an Apache Vhost virtual hosting feature. Let's use an experiment to achieve this effect: the Computer Browser input www.a.com display "I am a!", input www.b.com display "I am b!"

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/43/wKioL1WWOwrDhpY6AADhsQCc6AY361.jpg "title=" 4W) 8% %0{k9y7f]o_fdf@5yf.png "alt=" Wkiol1wwowrdhpy6aadhsqcc6ay361.jpg "/>

Construction Method:

I. Turn on the Apache Virtual Host feature to make this function effective: vim/usr/local/apache2/conf/httpd.conf find the following field and comment out the "#" in front of it (if not, add it manually), Wq save exit: Include conf/ Extra/httpd-vhosts.conf
 Two. Create a site directory and add content:cd /usr/local/apache2/htdocs/mkdir mkdir  touch /www.b.com/index.html touch /www.b.com/index.html  echo  ' I am A! '  > www.a.com/index.htmlecho  ' i am b! '  > www.b.com/index.html 
Three. Modify the virtual Host profile: Vim /usr/local/apache2/conf/extra/httpd-vhosts.conf modify it to the following configuration and save the:namevirtualhost *:80< virtualhost *:80>    serveradmin [email protected]      #邮箱     DocumentRoot  "/usr/local/apache2/htdocs/www.a.com"       #网站家目录     ServerName www.a.com     #访问所用域名      ErrorLog  "Logs/error_log"      #错误日志     CustomLog  "logs/ Access_log " common     #访问日志 </VirtualHost><VirtualHost *:80>     ServerAdmin [email protected]    DocumentRoot  "/usr/local /apache2/htdocs/www.b.com "    servername www.b.com    errorlog   "Logs/error_log"     CustomLog  "Logs/access_log"  common</VirtualHost>
Four. Restart the httpd service and access:/usr/local/apache2/bin/apachectl restartwww.a.com ====> "I am a!" www.b.com ====> "I am b!" the effect is successful.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/46/wKiom1WWPxXRMCjFAAFZc6MTFLI466.jpg "title=" n8{( PUZ_XV@J4489_MOCBGY.png "alt=" Wkiom1wwpxxrmcjfaafzc6mtfli466.jpg "/>

This article is from the IT Network blog, so be sure to keep this source http://liupengfang1015.blog.51cto.com/6627801/1670596

Apache Virtual Host build (single IP multi-site server configuration)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.