xamp在配置多站点已经有了很多预配置,这里只在在原来的基础上做一些增增减减。

  1. 启用虚拟主机
    $ sudo vim /opt/lampp/etc/httpd.conf

大约在488行,找到如下内容:

    484 # Real-time info on requests and configuration
    485 #Include etc/extra/httpd-info.conf
    486 
    487 # Virtual hosts
    488 Include etc/extra/httpd-vhosts.conf
    489 
    490 # Local access to the Apache HTTP Server Manual
    491 #Include etc/extra/httpd-manual.conf
  1. 虚拟主机配置

xampp为我们准备了一个专用于配置虚拟主机的文件了,去掉#号以删除其注释,然后编辑/opt/lampp/etc/extra /httpd-vhosts.conf文件,此文件中xampp为我们创建了两个虚拟主机的示例,我们把这两个示例注释掉。
然后在httpd-vhosts.conf中添加主机配置即可。

DocumentRoot /opt/lampp/www/evenvi ServerName blog.evenvi.com
DocumentRoot表示虚拟主机对应的路径,即网站目录,ServerName表示虚拟主机的访问地址。到这里基本的虚拟主机就配置完了。

  1. 添加一些权限控制
    Directory "/opt/lampp/www/site1">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

如果想妖通过域名访问,直接修改操作系统的相关host设置即可。

附:
重要的文件和目录

    文件                           目录           用途
    /opt/lampp/bin/              XAMPP 命令库。  例如 /opt/lampp/bin/mysql 可执行 MySQL 监视器。
    /opt/lampp/htdocs/              Apache 文档根目录。
    /opt/lampp/etc/httpd.conf      Apache 配制文件。
    /opt/lampp/etc/my.cnf      MySQL 配制文件。
    /opt/lampp/etc/php.ini      PHP 配制文件。
    /opt/lampp/etc/proftpd.conf      ProFTPD 配制文件。(从 0.9.5 版开始)
    /opt/lampp/phpmyadmin/config.inc.php    

phpMyAdmin 配制文件。


windows 下的配置基本和这个相同,这里附带一个http-vhosts.conf的配置文件。

<VirtualHost 127.0.0.2:80>
    ServerAdmin "127.0.0.2:80"  
    DocumentRoot "E:\workspace\kabao"
    ServerName 127.0.0.2
    ErrorLog "logs/kabao.log"
    CustomLog "logs/kabao.log" combined
</VirtualHost> 

DocumentRoot "E:\workspace"
<Directory "E:\workspace">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

以后可以像这样添加其他站点的配置

<VirtualHost 127.0.0.3:80>
    ServerAdmin "127.0.0.3:80"  
    DocumentRoot "E:/workspace/yyy"
    ServerName 127.0.0.3
    ErrorLog "logs/yyy.log"
    CustomLog "logs/yyy.log" combined
</VirtualHost> 

Tags: none

Related Posts:
  • [尚无相关文章]

Leave a Comment