简体   繁体   English

apache php Virtualhost

[英]apache php Virtualhost

I am trying to implement virtual host in my system. 我正在尝试在我的系统中实现虚拟主机。

I have used the below code for that. 我已经使用了以下代码。

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Users/shanker/Documents/content_booking/"  
    ServerName content.boking
    Alias /booking "/Users/shanker/Documents/content_booking/public/"
</VirtualHost>

also i have updated the hosts file as 我也更新了hosts文件

127.0.0.1 content.booking 127.0.0.1 content.booking

But I am getting the following errors: 但我收到以下错误:

---------------------------------------------------------
Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.
Error 403
---------------------------------------------------------

Can anybody please fix this issue. 任何人都可以解决这个问题。

Your ServerName is with one "o", and your hosts file entry is with "oo" (two). 您的ServerName有一个“o”,主机文件条目是“oo”(两个)。

Does it work once you fix that typo? 一旦你解决了这个错字,它有用吗?

If you do not include an index.[html|htm|php] in a directory, the default action may be to list all the files in that directory or more commonly for security, to throw this error. 如果在目录中没有包含索引。[html | htm | php],则默认操作可能是列出该目录中的所有文件,或者更常见的是为了安全性,以抛出此错误。

http://127.0.0.1/ causes Apache to look for index.[html|htm|php] files and if there isn't one there and your security doesn't allow listing the directory (which it shouldn't), this is the error. http://127.0.0.1/导致Apache查找索引。[html | htm | php]文件,如果没有那个,你的安全性不允许列出目录(它不应该),这个是错误。

Create an index.html file in the proper directory and see if that helps. 在正确的目录中创建一个index.html文件,看看是否有帮助。

First check your httpd.conf file in Apache and make sure Virtual hosts is on. 首先检查Apache中的httpd.conf文件,确保虚拟主机已打开。 (remove the '#' to turn on/uncomment). (删除'#'以打开/取消注释)。

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

next update your vhosts-file with some Directory options. 接下来使用一些Directory选项更新您的vhosts文件。

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Users/shanker/Documents/content_booking/"  
ServerName content.boking
<Directory "C:/Users/shanker/Documents/content_booking/">
  Options Indexes FollowSymLinks ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
Alias /booking "/Users/shanker/Documents/content_booking/public/"

Hope this helps. 希望这可以帮助。

OS X的权限等设置(开箱即用)以便从/Users/shanker/Sites提供Web文档,因此,如果这是与权限相关的问题,您可能只是尝试将代码移动到/Users/shanker/Sites/content_booking/目录并更新DocumentRoot指令以支持任何权限问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM