我也是用apache+mysql+php设的虚拟主机。现在可以编译php文件了。而mysql 的数据库也可以使用了
不知道还有什么地方没有完成的?我这个是算成功了吗?因为我一直没有将php和数据库连接过,所以还有个疑问~???

解决方案 »

  1.   

    那就连一下吧
    <?php
    $mysqlhost="localhost";
    $username="root";
    $password="123";
    $mysqldbname="test";
    $conn = @mysql_connect($mysqlhost,$username,$password);
    if(!$conn){
    echo("没能连通数据库服务器" );
    exit();
    }
    if(!@mysql_select_db($mysqldbname)){
    echo( "没能连通数据库");
    exit();
    }
    ?>
      

  2.   

    #
    # BindAddress: You can support virtual hosts with this option. This directive
    # is used to tell the server which IP address to listen to. It can either
    # contain "*", an IP address, or a fully qualified Internet domain name.
    # See also the <VirtualHost> and Listen directives.

    BindAddress * 这个加了没有。
      

  3.   

    #LoadModule vhost_alias_module modules/mod_vhost_alias.so
    去掉#了没?
    再看看这里的讨论
    http://www.douzhe.com/docs/bbsjh/3/13871.html
      

  4.   

    to icewolf_li:
        BindAddress * 这个是在什么地方添加的?我在httpd.conf里面加了以后,起httpd会出错!提示:
        Apache 1.3 configuration directives found
        please read /usr/share/doc/httpd-2.0.40/migration.html
      

  5.   

    我是在局域网下面测试的,我用的域名指向ip是局域网里面的ip。而test.company.com指向192.168.0.9 这个是在我买的域名那里配置的,我自己没有装dns。这些应该不会有影响吧?
      

  6.   

    你不要在dns那把test.company.com指向192.168.0.9先。
    直接修改system32\drivers\etc\hosts文件(linux系统的话是/etc/hosts),里面加一行映射
    192.168.0.9  test.company.com
    就行了。
    每次测试你都去改真实的dns设置不是要烦死。BindAddress的话你直接在httpd.conf里面搜索,他初始的配置应该就有的。
      

  7.   

    在httpd.conf里面没有BindAddress。不过我加上BindAddress *以后就报错啦
      

  8.   

    ### Section 3: Virtual Hosts
    #
    # VirtualHost: If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations
    # use only name-based virtual hosts so the server doesn't need to worry about
    # IP addresses. This is indicated by the asterisks in the directives below.
    #
    # Please see the documentation at 
    # <URL:http://httpd.apache.org/docs-2.0/vhosts/>
    # for further details before you try to setup virtual hosts.
    #
    # You may use the command line option '-S' to verify your virtual host
    # configuration.#
    # Use name-based virtual hosting.
    #ServerName server.company.com
    NameVirtualHost 192.168.0.9#
    # VirtualHost example:
    # Almost any Apache directive may go into a VirtualHost container.
    #The first VirtualHost section is used for requests without a known
    # server name.
    #<VirtualHost 192.168.0.9>
        ServerAdmin [email protected]
        DocumentRoot /home/test
        ServerName test.company.com
        ErrorLog logs/dummy-host.example.com-error_log
        CustomLog logs/dummy-host.example.com-access_log common
    </VirtualHost>
    这是我在httpd.conf里面设置的内容,其它的都为默认的配置