我已经阅读了很多关于虚拟主机设置的文章和帖子,但我无法弄清楚哪个是问题。
我有一台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,它会立即启动和停止。
我不明白我错过了什么。
答案 0 :(得分:0)
从包含行的开头删除哈希
apache httpd.conf
#Listen [::]:80
Listen *:8080
# Virtual hosts
include "conf/extra/httpd-vhosts.conf"