0

我已经阅读了很多关于虚拟主机设置的文章和帖子,但我无法找出问题所在。

我有一台 Win7 电脑,我在其中安装了一个 xampp 来管理我的 php + mysql 项目。默认情况下,Web 根目录是 C:\xampp\htdocs 为了避免与 Skype 冲突,我将 apache 设置为在端口 8080 上工作

如果我浏览到类似 localhost:8080/mysubdir 的内容,它工作正常。

我现在的想法是将 Apache 的 webroot 指向我电脑上的另一个目录:我想指向我的 webroot 的目录是 C:\Users\myuser\Google Drive\CODE_REPOS

我在网上搜索了一下,好像是通过VirtualHost可以的;这是我的配置

apache httpd.conf
#Listen [::]:80
Listen *:8080

# Virtual hosts
#Include "conf/extra/httpd-vhosts.conf"

这是我的 httpd-vhosts.conf

# Use name-based virtual hosting.
#
NameVirtualHost *:8080
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:8080>
    ServerAdmin admin@localhost.com
    DocumentRoot "C:/xampp/htdocs" # change this line with your htdocs folder
    ServerName localhost
    ServerAlias localhost
    <Directory "C:/xampp/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
<VirtualHost development.loc:8080>
    ServerAdmin admin@localhost.com
    DocumentRoot "C:/Users/myuser/Google Drive/CODE_REPOS" # change this line with your htdocs folder
    ServerName development.loc
    ServerAlias development.loc
    <Directory "C:/Users/myuser/Google Drive/CODE_REPOS">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

现在 C:\Windows\System32\drivers\etc\hosts 中的代码

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
    127.0.0.1       localhost
    127.0.0.1       development.loc

如果我停止 Apache,请取消注释 #Include "conf/extra/httpd-vhosts.conf" 行并尝试再次启动 Apache,它会立即启动和停止。

我不明白我错过了什么。

4

1 回答 1

0

从包含行的开头删除哈希

    apache httpd.conf
    #Listen [::]:80
    Listen *:8080

    # Virtual hosts
    include "conf/extra/httpd-vhosts.conf"
于 2013-11-10T10:44:47.860 回答