centos下xampp建立虚拟目录绑定域名

转自:http://www.9streets.cn/art-php-535.html

 

1,第一步:

xampp默认没有开启虚拟目录的功能
需要修改/opt/lampp/etc/httpd.conf文件
搜索下面的代码

# Virtual hosts

# Include etc/extra/httpd-vhosts.conf
去掉前面的#,即:Include etc/extra/httpd-vhosts.conf

2,第二步:

xampp管理虚拟目录文件是:/opt/lampp/etc/httpd-vhosts.conf
[root@localhost extra]# vi httpd-vhosts.conf
     ServerAdmin webmaster@dummy-host2.example.com    #管理服务器的邮箱 一般都不需要填写
     DocumentRoot /www/docs/dummy-host2.example.com   #网站的目录
     ServerName dummy-host2.example.com               #需要绑定的域名
     ServerAlias  www.example.com                     #绑定多个域名
     DirectoryIndex example.php                       #设置默认的访问的页面
     ErrorLog logs/dummy-host2.example.com-error_log  #错误日志目录

最重启apache服务器就配置成功了

 


例如需要建立一个It资讯网站,网站目录是:/opt/lampp/htdocs/itinfo
需要绑定两个域名www.chinajquery.com www.jquerychina.com
那我们的vhosts.conf最后添加以下代码就可以

  DocumentRoot /opt/lampp/htdocs/itinfo
  ServerName   www.chinajquery.com
  ServerAlias  www.jquerychina.com
  DirectoryIndex test.php

最后重启apache服务器
[root@localhost extra] /opt/lampp/lampp restart
测试一下配置虚拟目录有没有成功
添加
192.168.139.129    www.chinajquery.com
192.168.139.129    www.jquerychina.com
到 /etc/hosts
[root@localhost extra]/etc/init.d/network restart      重启网卡
然后在浏览器输入www.chinajquery.com出现下面的界面说明配置成功

posted on 2016-02-20 20:25  ziyi_ang  阅读(541)  评论(0编辑  收藏  举报

导航