Apache服务器一个IP多个站点的配置方法示例
在日常的网站发布中很多情况下都无法做到一个IP对应一个站点,在IP4的情况下IP的资源是相对有限的。然而作为最流行的Apache自然也考虑到这种情况,那么接下来看看apache服务器怎么配置一个IP多个站点。
在httpd.conf中找到 "# Virtual hosts",并添加如下行
复制代码 代码如下:ServerName 你的域名
HostNameLookups off
例子
?
?1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | NameVirtualHost 192.168.1.104 ? <VirtualHost 192.168.1.104> ???? ServerName php ???? ServerAdmin test@gmail ???? DocumentRoot /data/www1/ ???? DirectoryIndex index.php index index index.shtml ???? Errorlog /usr/local/apache2/logs/wwwError_log ???? Loglevel warn ???? HostNameLookups off ???? <Directory /data/www1/> ????? AllowOverride None ????? Order allow,deny ????? Allow from all ???? </Directory> </VirtualHost> ? <VirtualHost 192.168.1.104> ???? ServerName bbs.php ???? ServerAdmin test@gmail ???? DocumentRoot /data/www2/ ???? DirectoryIndex index.php index index index.shtml ???? Errorlog /usr/local/apache2/logs/bbsError_log ???? Loglevel warn ???? HostNameLookups off ???? <Directory /data/www2/> ????? AllowOverride None ????? Order allow,deny ????? Allow from all ???? </Directory> </VirtualHost> |
?
上述的例子IP都是192.168.1.104,域名分别是php和bbs.php。因而可知apahce是通过ServerName来识别同一个IP下的不同站点的。
在实际应用中你只需要将IP192.168.1.104、域名php和bbs.php分别改成你的IP和域名即可。
上一篇:解决PHPstudy Apache无法启动的问题【亲测有效】
新加坡服务器的速度怎么样
深圳机房IDC数据中心如何办理托
超融合最少需要几台服务器
泰国服务器供应商哪家的比较好?
海外服务器哪个好?怎么选
什么是Isp路由服务器?有什么用
泰国服务器租赁和托管分别有哪些
租用新加坡服务器时应该注意什么
超融合一体机和服务器的区别
泰国服务器租用怎么选租用到好的