亿软首页 公司动态 业务项目 开发案例 电商产品 技术支持 客户留言
       
  Apache虚拟主机配置 作者: F.C.X 2013-04-08
   

<p>在网上查了很多资料配置Apache的虚拟主机,但都是讲得一知半解,没有系统、完整的配置过程。</p> <p>经自己研究后,得到了完整版的配置方法。</p> <p>1、安装Apache</p> <p>省略</p> <p>2、配置Apache</p> <p>打开Apache的配置文件httpd.Conf,位置:在Apache安装路径下的conf下</p> <p>找到以下内容,指定Apache的端口号,这里设置为:80</p> <div class="cnblogs_Highlighter"> <div> <div id="highlighter_916142" class="syntaxhighlighter nogutter html ie"> <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="code"> <div class="container"> <div class="line number1 index0 alt2"><code class="html plain">Listen 80</code></div> </div> </td> </tr> </tbody> </table> </div> </div> </div> <p>3、配置Apache虚拟主机</p> <p>继续以上步骤:</p> <p>将Include前的#去掉</p> <div class="cnblogs_code"> <pre> # Virtual hosts<br />Include conf/extra/httpd-vhosts.conf 启用相应PROXY模块 LoadModule proxy_module modules/mod_proxy.so<br />#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so<br />#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so<br />LoadModule proxy_connect_module modules/mod_proxy_connect.so<br />#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so<br />LoadModule proxy_http_module modules/mod_proxy_http.so<br />#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so</pre> </div> <p>保存修改后的httpd.Conf</p> <p>4、配置httpd-vhosts.Conf</p> <p>打开httpd-vhosts.Conf文件,该文件内容如下:</p> <p>#<br /> # Virtual Hosts<br /> #<br /> # If you want to maintain multiple domains/hostnames on your<br /> # machine you can setup VirtualHost containers for them. Most configurations<br /> # use only name-based virtual hosts so the server doesn't need to worry about<br /> # IP addresses. This is indicated by the asterisks in the directives below.<br /> #<br /> # Please see the documentation at <br /> # &lt;<a href="http://httpd.apache.org/docs/2.2/vhosts/">URL:http://httpd.apache.org/docs/2.2/vhosts/</a>&gt;<br /> # for further details before you try to setup virtual hosts.<br /> #<br /> # You may use the command line option '-S' to verify your virtual host<br /> # configuration.</p> <p>#<br /> # Use name-based virtual hosting.<br /> #<br /> NameVirtualHost *:80</p> <p>#<br /> # VirtualHost example:<br /> # Almost any Apache directive may go into a VirtualHost container.<br /> # The first VirtualHost section is used for all requests that do not<br /> # match a ServerName or ServerAlias in any &lt;VirtualHost&gt; block.<br /> #<br /> &lt;VirtualHost *:80&gt;<br /> &nbsp; ServerAdmin <a href="mailto:4183574@qq.com">4183574@qq.com</a><br /> ServerName <a href="http://www.cheovo.cn">www.cheovo.cn</a><br /> ProxyRequests Off<br /> &lt;Proxy *&gt;<br /> Order deny,allow<br /> Allow from all<br /> &lt;/Proxy&gt;<br /> ProxyPass / <a href="http://www.cheovo.cn:81/">http://www.cheovo.cn:81/</a><br /> ProxyPassReverse /&nbsp; <a href="http://www.cheovo.cn:81/">http://www.cheovo.cn:81/</a><br /> &lt;/VirtualHost&gt;</p> <p>&lt;VirtualHost *:80&gt;<br /> &nbsp; ServerAdmin <a href="mailto:4183574@qq.com">4183574@qq.com</a><br /> ServerName <a href="http://www.baojiaqi.com">www.baojiaqi.com</a><br /> ProxyRequests Off<br /> &lt;Proxy *&gt;<br /> Order deny,allow<br /> Allow from all<br /> &lt;/Proxy&gt;<br /> ProxyPass / <a href="http://www.baojiaqi.com:8000/">http://www.baojiaqi.com:8000/</a><br /> ProxyPassReverse /&nbsp; <a href="http://www.baojiaqi.com:8000/">http://www.baojiaqi.com:8000/</a><br /> &lt;/VirtualHost&gt;<br /> 这样,访问<a href="http://www.cheovo.cn">www.cheovo.cn</a>就代理<a href="http://www.cheovo.cn:81">www.cheovo.cn:81</a>的内容</p> <p>重启服务即可。</p>

发表评论
 
业务QQ:4183574-点击联系客服!  8024682-点击联系客服!      微信号:4183574      业务与技术咨询:13787796858
公司名称:湖南亿软软件有限公司        网站备案号:湘ICP备14000826号-1        地址:岳麓区延农创业大厦7楼        售后:0731-87272682
 
友情链接:ZOL应用下载   下载之家   非凡软件站   天极下载   下载银行   中国下载吧   免费网盘   电脑之家   格子啦   华彩软件站   ZOL手机应用