centos绑定多个域名
2016-03-22 02:57
507 查看
正在使用aliyun主机,运行centos6.4 64位系统,安装lamp环境后进行域名绑定。配置文件如下:
通过查看官方文档已经找到答案:
# Ensure that Apache listens on port 80
Listen 80
必须开启
<VirtualHost *:80> DocumentRoot /var/www/html ServerName 120.24.54.xxx </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/html/domain1 ServerName domain.com ServerAlias *.domain.com </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/html/domain2 ServerName domain.com ServerAlias *.domain.com </VirtualHost>
然后通过www.domain1.com可以访问指向/var/www/html/domain1目录的网站,但是通过www.domain1.com访问同样是指向/var/www/html/domain1,通过IP 120.24.54.xxx访问也是指向domai1目录,配置文件其他地方没动过。我想要通过IP访问就指向html目录,通过域名访问就指向对应的目录。
通过查看官方文档已经找到答案:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /www/example1 ServerName www.example.com # Other directives here </VirtualHost> <VirtualHost *:80> DocumentRoot /www/example2 ServerName www.example.org # Other directives here </VirtualHost>
必须开启
NameVirtualHost *:80,否则无论绑定多少个域名,全部都会指向第一个virtualhost的documentroot
相关文章推荐
- 二、Linux学习之centOS的的setup
- 一、linux学习之centOS系统安装(VMware下安装)
- Centos下Yum安装PHP5.5,5.6,7.0
- linux commands ---2 ,学习vim编辑器如何使用的方法。
- linux 下启动java程序 的方法
- linux编程中与时间相关的问题总结
- linux如何挂载U盘
- linux command ---1
- Linux下线程pthread以及锁的一些总结和代码参考
- linux(unbutn)安装java,java升级
- 64位 centos 服务器 编译安装 gcc-4.6.2 和 codeviz
- centos6 与 7 其中的一些区别
- “error: command 'x86_64-linux-gnu-gcc' failed with
- Linux IO模式
- CentOS下如何完全卸载MySQL?解决卸载不干净的问题
- centos下配置多个SVN版本库方法
- 从ramdisk根文件系统启动Linux成功,及使用initramfs启动linux
- 阿里云Centos7安装Mysql方法
- CentOS 软件安装--卓越软件管理
- U-boot mkimage指定Linux内核地址时的两种方式