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)