apache服务器如何实现多IP配置的方法实例
2011-05-19 16:40
806 查看
apache服务器如何实现多IP配置的方法实例
开启虚拟主机配置文件
对httpd.conf进行设置:
1.注释以下三行
#ServerAdmin
#ServerName
#DocumentRoot
2.去掉mod_proxy.so和mod_proxy_ajp.so的注释
3.#Virtual hosts
#Include conf/extra/httpd-vhosts.conf (查找这行,把前面的#去掉)
/conf/extra/httpd-vhosts.conf
4.打开 /conf/extra/httpd-vhosts.conf
#192.168.1.24为本地Ip
NameVirtualHost 192.168.1.24:80
# php项目
<VirtualHost 192.168.1.24:80>
<Directory "D:/phproot/phpmyadmin">
DirectoryIndex index.php
</Directory>
ServerAdmin baibiao @gmail.com
ServerName email.sinoepiboly.com
#ServerAlias email.sinoepiboly.com
DocumentRoot D:/phproot/phpmyadmin
</VirtualHost>
==================================================================
方法二:
多二级域名主机开发环境设置说明
第一步 DNS解析实现
找到本机的host文件,一般在 C:WINNTsystem32driversetc,在文件结尾添加:
127.0.0.1 localhost
127.0.0.1 www.com.cn
127.0.0.1 home.com.cn
127.0.0.1 mail.com.cn
127.0.0.1 music.com.cn
127.0.0.1 browseusers.com.cn
127.0.0.1 search.com.cn
127.0.0.1 invite.com.cn
127.0.0.1 rank.com.cn
127.0.0.1 blog.com.cn
127.0.0.1 favorites.com.cn
127.0.0.1 forum.com.cn
127.0.0.1 groups.com.cn
127.0.0.1 events.com.cn
127.0.0.1 classifieds.com.cn
127.0.0.1 signup.com.cn
192.168.6.153 i.com.cn
192.168.6.153 x.com.cn
其中
192.168.6.2 i.com.cn
192.168.6.2 x.com.cn
技术人员不作修改,是美工页面专用的
第二步:apache 设置
打开httpd.conf,以music.com.cn为例,其他栏目类似添加,在文件最后加入:
1. 保证
Listen 80
2. 打开注释
NameVirtualHost *:80
3. 在末尾添加
<VirtualHost *:80>
ServerAdmin x_cn@msn.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/espace/music"
ServerName www.3ppt.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin x_cn@msn.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/espace/blog"
ServerName blog.com.cn
</VirtualHost>
...
重启即可,Apache虚拟主机设置完成
基于IP地址的虚拟主机配置
Listen 80
DocumentRoot /www/example1
ServerName www.example1.com
DocumentRoot /www/example2
ServerName www.example2.org
基于IP和多端口的虚拟主机配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
DocumentRoot /www/example1-80
ServerName www.example1.com
DocumentRoot /www/example1-8080
ServerName www.example1.com
DocumentRoot /www/example2-80
ServerName www.example1.org
DocumentRoot /www/example2-8080
ServerName www.example2.org
单个IP地址的服务器上基于域名的虚拟主机配置:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
在多个IP地址的服务器上配置基于域名的虚拟主机:
Listen 80
# This is the “main” server running on 172.20.30.40
ServerName server.3ppt.com
DocumentRoot /www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
DocumentRoot /www/example1
ServerName www.example1.com
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …
在不同的端口上运行不同的站点:
基于多端口的服务器上配置基于域名的虚拟主机。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.example1.com
DocumentRoot /www/domain-80
ServerName www.example1.com
DocumentRoot /www/domain-8080
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
基于域名和基于IP的混合虚拟主机的配置:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot /www/example1
ServerName www.example1.com
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
本文出自 “完美主义者” 博客,请务必保留此出处http://kokoxoxo.blog.51cto.com/3115159/568691
开启虚拟主机配置文件
对httpd.conf进行设置:
1.注释以下三行
#ServerAdmin
#ServerName
#DocumentRoot
2.去掉mod_proxy.so和mod_proxy_ajp.so的注释
3.#Virtual hosts
#Include conf/extra/httpd-vhosts.conf (查找这行,把前面的#去掉)
/conf/extra/httpd-vhosts.conf
4.打开 /conf/extra/httpd-vhosts.conf
#192.168.1.24为本地Ip
NameVirtualHost 192.168.1.24:80
# php项目
<VirtualHost 192.168.1.24:80>
<Directory "D:/phproot/phpmyadmin">
DirectoryIndex index.php
</Directory>
ServerAdmin baibiao @gmail.com
ServerName email.sinoepiboly.com
#ServerAlias email.sinoepiboly.com
DocumentRoot D:/phproot/phpmyadmin
</VirtualHost>
==================================================================
方法二:
多二级域名主机开发环境设置说明
第一步 DNS解析实现
找到本机的host文件,一般在 C:WINNTsystem32driversetc,在文件结尾添加:
127.0.0.1 localhost
127.0.0.1 www.com.cn
127.0.0.1 home.com.cn
127.0.0.1 mail.com.cn
127.0.0.1 music.com.cn
127.0.0.1 browseusers.com.cn
127.0.0.1 search.com.cn
127.0.0.1 invite.com.cn
127.0.0.1 rank.com.cn
127.0.0.1 blog.com.cn
127.0.0.1 favorites.com.cn
127.0.0.1 forum.com.cn
127.0.0.1 groups.com.cn
127.0.0.1 events.com.cn
127.0.0.1 classifieds.com.cn
127.0.0.1 signup.com.cn
192.168.6.153 i.com.cn
192.168.6.153 x.com.cn
其中
192.168.6.2 i.com.cn
192.168.6.2 x.com.cn
技术人员不作修改,是美工页面专用的
第二步:apache 设置
打开httpd.conf,以music.com.cn为例,其他栏目类似添加,在文件最后加入:
1. 保证
Listen 80
2. 打开注释
NameVirtualHost *:80
3. 在末尾添加
<VirtualHost *:80>
ServerAdmin x_cn@msn.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/espace/music"
ServerName www.3ppt.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin x_cn@msn.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/espace/blog"
ServerName blog.com.cn
</VirtualHost>
...
重启即可,Apache虚拟主机设置完成
基于IP地址的虚拟主机配置
Listen 80
DocumentRoot /www/example1
ServerName www.example1.com
DocumentRoot /www/example2
ServerName www.example2.org
基于IP和多端口的虚拟主机配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
DocumentRoot /www/example1-80
ServerName www.example1.com
DocumentRoot /www/example1-8080
ServerName www.example1.com
DocumentRoot /www/example2-80
ServerName www.example1.org
DocumentRoot /www/example2-8080
ServerName www.example2.org
单个IP地址的服务器上基于域名的虚拟主机配置:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
在多个IP地址的服务器上配置基于域名的虚拟主机:
Listen 80
# This is the “main” server running on 172.20.30.40
ServerName server.3ppt.com
DocumentRoot /www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
DocumentRoot /www/example1
ServerName www.example1.com
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …
在不同的端口上运行不同的站点:
基于多端口的服务器上配置基于域名的虚拟主机。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.example1.com
DocumentRoot /www/domain-80
ServerName www.example1.com
DocumentRoot /www/domain-8080
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
基于域名和基于IP的混合虚拟主机的配置:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot /www/example1
ServerName www.example1.com
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
本文出自 “完美主义者” 博客,请务必保留此出处http://kokoxoxo.blog.51cto.com/3115159/568691
相关文章推荐
- Tp5—隐藏public的方法(修改Apache服务器的配置实现)
- Apache服务器一个IP多个站点的配置方法示例
- Apache服务器如何限制IP访问:第一招——配置文件
- Apache 获取真实ip的配置的实现方法
- android studio如何配置环境变量并实现native方法
- Apache服务器实现不同域名部署不同SSL证书方法
- 如何通过配置IPMI实现远程管理服务器
- 简单实现MySQL服务器的优化配置方法
- Apache-支持shtml实现include文件解析的配置方法
- 配置apache apache服务器如何配置多站点
- Docker 配置固定IP及桥接的实现方法
- 实现nginx&php服务器配置的非主流配置方法
- apache一个IP多个站点的配置方法
- 如何在一台服务器上实现多个web站点的方法
- apache + resin的多机部署方案实现方法WEB服务器
- 正确维护配置Apache服务器的方法 保护系统安全
- Rsync实现服务器间文件数据同步配置实例
- CentOS 7.0 安装配置LAMP服务器方法(Apache+PHP+MariaDB)
- 让Apache支持shtml实现include文件解析的配置方法
- apache服务器如何实现301重定向