Apache,我可以有多个 documentRoot 吗?
我正在构建一个 Zend 网站。该项目(本地)具有以下结构:
/app
/controllers
/views
/public
/css
/images
/js
.htaccess
index.php
由于 .htaccess 和 index.php 文件驻留在公共目录中,因此公共目录必须能够被 apache 识别为网站的文档根和根目录。
所以我应该去编辑 httpd.conf 文件中的“DocumentRoot from c:/wamp/www/ to c:/wamp/www/my-zend-app/public”。 但如果我这样做,我无法访问“c:/wamp/www/”内的其他项目..我可以保留两个文档根吗?
编辑 编辑文件:
[httpd-vhost.conf]
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:\wamp\www\my-zend-app\application\public"
ServerName website.loc
ErrorLog "C:\wamp\www\my-zend-app\application\public\error.log"
CustomLog "C:\wamp\www\my-zend-app\application\access.log" common
</VirtualHost>
我尝试取消注释有关“httpd-vhost.conf”的httpd.conf行,并在编辑Windows主机文件后立即
127.0.0.1 website.loc
添加:但它不起作用。我正在运行WAMPSERVER 2.1
I'm building a Zend website.The project (local) has the following structure:
/app
/controllers
/views
/public
/css
/images
/js
.htaccess
index.php
Because the .htaccess and index.php files reside within th public directory,the public directory must be identifiable by apache as the website's document root and root directory.
So I should go to edit the "DocumentRoot from c:/wamp/www/ to c:/wamp/www/my-zend-app/public" inside the httpd.conf file.
But if I do so I can't reach my other projects inside "c:/wamp/www/".. can I keep both the documentRoots?
EDIT
I tried with uncommenting the httpd.conf line about "httpd-vhost.conf" and edited the file:
[httpd-vhost.conf]
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:\wamp\www\my-zend-app\application\public"
ServerName website.loc
ErrorLog "C:\wamp\www\my-zend-app\application\public\error.log"
CustomLog "C:\wamp\www\my-zend-app\application\access.log" common
</VirtualHost>
right after edited the windows hosts file adding:
127.0.0.1 website.loc
but it's not working.I'm running WAMPSERVER 2.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加
指令 到新文档根目录的
指令Add a
<Directory>
Directive to your<VirtualHost>
directive for the new document root使用不同的端口或使用 ServerName 创建第二个虚拟主机(并编辑主机文件以在本地解析。
更简单的方法是在不同的端口上使用不同的虚拟主机,但请记住在主配置上添加
Listen yourPort
让 apache 也监听该端口。Create a second virtual host using a different port or using ServerName (and editing hosts file to resolve locally.
The easier one is just using different virtual hosts on different ports but remember also adding
Listen yourPort
on the main config to make apache listen that port too.