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

WBOY
Lepaskan: 2016-06-23 14:09:05
asal
1203 orang telah melayarinya

如何进一步在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>
Salin selepas log masuk



回复讨论(解决方案)


* 换成 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>
Salin selepas log masuk

上面要不要加 NameVirtualHost 2.3.4.5:80?

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

感谢,现在明白了。

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!