通用的 apache vhost 配置文件

Listen 88                                                   # 侦听端口号,默认是80,不能重复,会报错

Alias /db /home/www/phpmyadmin    # 别名访问,如 http://localhost/db

<VirtualHost *:88>                                         # 这里的端口号必须已经开放侦听
    #ServerAdmin webmaster@host.example.com          # 管理员联系方式,可不写
    DocumentRoot "/xampp/htdocs/project/public"      # 虚拟主机的根目录
    #ServerName host.example.com                        # 虚拟主机域名(或IP)
    #ServerAlias www.host.example.com                  # 虚拟主机域名别名,*表示通配
    ErrorLog "logs/project-error.log"                  # 虚拟主机错误日志
    CustomLog "logs/project-access.log" common       # 虚拟主机访问日志


    <Directory /home/www/phpmyadmin>                    # 设置虚拟主机主目录的访问限制属性
        Options FollowSymLinks
        DirectoryIndex index.php                         # 默认脚本
        Order Deny,Allow                                   # 访问权限优先级
        Deny from All                                       # 禁止所有用户(All),或填写IP,或IP段(如 192.168.1.0/24)
        Allow from 192.168.1.0/24                            # 允许指定IP段
        Allow from 192.168.0.0/16;                           # 可允许多个指定IP段
        Allow from 172.16.0.0/12;
        Allow from 10.0.0.0/8;
        Allow from 127.0.0.0/8;

        <IfModule mod_php5.c>                              # php 脚本执行权限和配置
                AddType application/x-httpd-php .php

                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_admin_flag allow_url_fopen Off
                php_value include_path .
                php_admin_value upload_tmp_dir /tmp
                php_admin_value open_basedir /usr/share/library/
        </IfModule>

    </Directory>

</VirtualHost>