Apache 别名问题,雪豹

发布于 2024-08-16 05:51:47 字数 661 浏览 1 评论 0 原文

我正在使用 Snow Leopard 通过 PHP 进行 Web 开发。我的主目录中有一个文件夹,用作项目的 Eclipse 工作区。我想将它用作 Apache 中的部署目录,以便我所做的任何更改都将立即可见。

为此,我在 httpd.conf 中创建了一个别名,如下所示:

Alias /mysite/ "/Users/mysuser/workspace/mysite"
<Directory "/Users/victor/workspace/mysite">
  Order allow,deny
  Allow from all
</Directory>

但是,当我尝试访问 http://localhost /mysite/index.php 我得到:

   Forbidden
   You don't have permission to access /mysite/index.php on this server.

我已经检查了该文件夹的权限,所有用户都可以对其进行读/写/执行。

我错过了什么吗?另外,除了使用指向我的工作区的别名之外,还有更好的替代方法吗? 谢谢,维克多。

I`m using Snow Leopard for web development with PHP. I have a folder in my home directory which is used as the eclipse workspace for the project. I would like to use it as my deployment directory in Apache, so that any changes that i make will be instantly visible.

For that purpose i created an Alias in httpd.conf as follow:

Alias /mysite/ "/Users/mysuser/workspace/mysite"
<Directory "/Users/victor/workspace/mysite">
  Order allow,deny
  Allow from all
</Directory>

However, when i try to access http://localhost/mysite/index.php i get:

   Forbidden
   You don't have permission to access /mysite/index.php on this server.

I have checked the permissions of the folder and all users can read/write/execute on it.

Am i missing something ? Also, is there a better alternative to using aliases pointing to my workspace ?
Thanks, Victor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一曲爱恨情仇 2024-08-23 05:51:47

确保上面的所有文件夹(很可能是 /Users/mysuser)都具有读取/执行的权限。当为目录设置执行位时,将授予遍历其树以访问文件或子目录的能力。

为了回答你问题的后半部分,我总是使用VirtualHosts,并在我的/etc/hosts<中定义主机名(即127.0.0.1 mysite.local) /代码> 文件。这样您就不太可能在使用绝对路径时遇到问题。您的“模板”文件可以链接到 /css/main.css ,而不必担心基本路径问题...

Make sure that all the folders above (most likely /Users/mysuser) have permissions for any to read/execute. The execute bit when set for a directory, grants the ability to traverse its tree in order to access files or subdirectories.

To answer the second half of your question, I always use VirtualHosts, and define hostnames (i.e. 127.0.0.1 mysite.local) in my /etc/hosts file. This way you are less likely to have problems with using absolute paths. Your "template" files can link to /css/main.css without having to worry about base path issues...

苏大泽ㄣ 2024-08-23 05:51:47

@gnarf 在第一段中是正确的:

确保上面的所有文件夹(最有可能的是 /Users/mysuser)都具有读取/执行的权限。为目录设置执行位后,将授予遍历其树以访问文件或子目录的能力。

具体来说,解决此问题的方法是转到终端,cd 到这些文件所在的正确目录并键入:

sudo chmod 0755 mysite

如果由于某种原因它仍然不起作用,您可能需要对目录中的文件执行相同的操作。作为最后的手段,只是为了测试权限不再是问题,尝试将它们 chmod 为 0777(暂时的,因为如果您保留它,这将是一个安全漏洞)。

@gnarf was correct in the first paragraph:

Make sure that all the folders above (most likely /Users/mysuser) have permissions for any to read/execute. The execute bit when set for a directory, grants the ability to traverse its tree in order to access files or subdirectories.

Specifically, the way to fix this problem is to go to Terminal, cd to the proper directory where those files are located and type:

sudo chmod 0755 mysite

You might want to do the same to the files inside the directory if for some reason it still doesn't work. And as a last resort, just to test that permissions aren't the issue any longer, try to chmod them to 0777 (temporarily, as this is a security hole if you leave it).

给不了的爱 2024-08-23 05:51:47

10.6/10.5 的 ALIAS/REDIRECT 实现中有一个严重的错误(更不用说他们蹩脚的 apache 设置范例)。

您在服务器管理中创建的任何“别名”或“重定向”都在参数周围加上引号... 指令...在生成的 .conf 文件中。我不认为这些参数中的任何一个都应该有引号。我已经为此苦苦挣扎了很长时间,我再也无法区分上下了...

解决方案...在服务器中设置基本的 VHost 结构管理员,然后停止使用它!进入在 /etc/apache2/Sites 中创建的 .conf 文件并手动添加 mod_alias 指令。这就是服务器管理的输出的样子..

Alias "/include/" "/ServiceData/Web/mabishu/include/"
Alias "/collaboration" "/usr/share/collaboration"
Alias "/error/" "/usr/share/httpd/error/"
Redirect temp "http://www.osxserversux.com/" "http://osxserver.com/"

这就是它应该看起来的样子,以及实际工作的样子,(我认为)...

Alias /include/ /ServiceData/Web/mabishu/include/
Alias /collaboration /usr/share/collaboration
Alias /error/ /usr/share/httpd/error/
Redirect temp http://www.osxserversux.com/ http://osxserver.com/

从这一点开始,永远不要在“服务器管理”中的“Web”中点击保存”再次。如果您这样做,我们会很乐意为您回复所有报价!

整个网络管理,特别是“别名”“面板”,是苹果公司在让事情变得更容易的过程中犹豫不决的一个可怕的例子。他们重新命名约定,使研究解决方案成为一场噩梦,而且它们的实施也被破坏。更不用说他们应该使用 mod_rewrite 来代替......最重要的是,他们的专有设置方法的文档很少,呃!

我喜欢 Apple,但 Mac OS X 服务器的一些挫败感和配置选项的缺乏确实是不可原谅和令人烦恼的。

There is a SERIOUS bug in 10.6/10.5's ALIAS/REDIRECT implementation (not to mention their lame apache setup paradigm).

Any of the "Aliases" or "Redirects" you make in Server Admin have quotes around the arguments... as do <DocumentRoot "XXX">, and <Directory "XXX"> directives... in the resulting .conf files. I don't think ANY of these parameters are SUPPOSED to have quotes.. I've been struggling with this for so long I can't tell up from down anymore...

Solution... Set up your basic VHost structure in server admin, then stop using it!! Go into the .conf files it has created in /etc/apache2/Sites and manually add your mod_alias directives. This is What Server Admin's output looks like..

Alias "/include/" "/ServiceData/Web/mabishu/include/"
Alias "/collaboration" "/usr/share/collaboration"
Alias "/error/" "/usr/share/httpd/error/"
Redirect temp "http://www.osxserversux.com/" "http://osxserver.com/"

This is what it SHOULD look like, and what actually works, (I think)...

Alias /include/ /ServiceData/Web/mabishu/include/
Alias /collaboration /usr/share/collaboration
Alias /error/ /usr/share/httpd/error/
Redirect temp http://www.osxserversux.com/ http://osxserver.com/

And from this point on, NEVER hit save in "Web" in "Server Admin" again. If you do it will happily put all the quotes back for you!

This entire Web Administration, and specifically the "Aliases" "panel" is a hideous example of Apple faltering in their quest to make things easier. They rename conventions, making researching solutions a nightmare, and their implementation is broken. Not to mention they should have used mod_rewrite instead... Top it all off with scant documentation of their proprietary setup method, and ugh!

I LOVE Apple, but some of the frustrations and lack of configuration options of Mac OS X server are really inexcusable and annnoying.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文