Home  >  Article  >  Backend Development  >  apache 设置子域名使用不同的IP地址。

apache 设置子域名使用不同的IP地址。

WBOY
WBOYOriginal
2016-06-23 14:09:051202browse

如何进一步在apache的httpd.conf里,设置子域名,且子域名使用独立的IP地址。比如mydomian.com使用IP为1.2.3.4;www.sub.mydomian.com使用IP为2.3.4.5?


#省略LoadModuleListen 80User apacheGroup apacheServerAdmin root@localhostServerName www.mydomian.com:80UseCanonicalName Off<Directory />    Options FollowSymLinks    AllowOverride None</Directory><Directory "/var/www/html">    Options Indexes FollowSymLinks    AllowOverride All    Order allow,deny    Allow from all</Directory>DirectoryIndex index.html index.html.varAccessFileName .htaccess#上面的代码是httpd原配的,#省略若干行#下面的代码是网上找到的,直接添加在httpd结尾处,设置VirtualHost,#重新写一遍mydomian.com和sub.mydomian.com#浏览器貌似可以打开,但是这样写是不是合理呢?NameVirtualHost *:80<VirtualHost *:80>    ServerName mydomian.com    ServerAlias www.mydomian.com    DocumentRoot /var/www/html    <directory "/var/www/html">        Options Indexes FollowSymLinks        AllowOverride all        Order Deny,Allow        Deny from all        Allow from all    </directory></VirtualHost><VirtualHost *:80>    ServerName sub.mydomian.com    ServerAlias www.sub.mydomian.com    DocumentRoot /var/www/html/sub	<directory "/var/www/html/sub">        Options Indexes FollowSymLinks        AllowOverride all        Order Deny,Allow        Deny from all        Allow from all    </directory></VirtualHost>



回复讨论(解决方案)


* 换成 ip


* 换成 ip
只要这样吗?

<VirtualHost 2.3.4.5:80>    ServerName sub.mydomian.com    ServerAlias www.sub.mydomian.com    DocumentRoot /var/www/html/sub    <directory "/var/www/html/sub">        Options Indexes FollowSymLinks        AllowOverride all        Order Deny,Allow        Deny from all        Allow from all    </directory></VirtualHost>

上面要不要加 NameVirtualHost 2.3.4.5:80?

是的,不需要
给你个链接  http://jingyan.baidu.com/article/363872ec870f6e6e4ba16feb.html
描述的很清楚了

感谢,现在明白了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn