赞普& Apache:别名“访问被拒绝”

发布于 2024-11-03 16:18:24 字数 1265 浏览 4 评论 0原文

我刚刚在我的 Arch Linux 系统上安装了 Xampp。我现在想做的:

我的 PHP 工作目录位于我的主文件夹中(位于 /home/luke/PHP)。我希望 Apache 访问这两个文件,因此我遵循了 Xampp 安装指南 Arch Linux Wiki 并为此目录创建了一个别名。 这就是我的 httpd.conf(别名部分)的样子:

Alias /PHP /home/luke/PHP
<directory /home/luke/PHP>
    AllowOverride FileInfo Limit Options Indexes
    Order allow,deny
    Allow from all
</directory>

之后,我将 home/luke/PHP 文件夹的权限更改为 777(使用 chmod)。我重新启动了 Xampp,当我尝试导航到 http://localhost/PHP 时,得到了 403

Apache 服务器在 http-User(存在)和http-组。因此,我在我的组中添加了 http-User(来自我的用户的 luke 组,使用 chown-tool)。我重新启动服务器,同样的错误。

这是 error_log 文件(的一部分):

[Sun Apr 24 18:05:37 2011] [error] [client 127.0.0.1] (13)Keine Berechtigung: access to /PHP/ denied
[Sun Apr 24 18:10:30 2011] [error] [client 127.0.0.1] (13)Keine Berechtigung: access to /PHP/ denied
[Sun Apr 24 18:10:30 2011] [error] [client 127.0.0.1] (13)Keine Berechtigung: access to /PHP/ denied

因此,我创建的别名应该可以工作,但是我需要做什么才能使 Apache 可以访问我的 /home/luke/PHP 文件夹服务器?

我还尝试在 htdocs 文件夹中创建符号链接,但这也不起作用。

I just installed Xampp on my Arch Linux system. What i want to do now:

My PHP working directory is located in my home-folder (at /home/luke/PHP). I want Apache to access those files two, so i followed the Xampp Installation guide on the Arch Linux Wiki and created an Alias for this Directory.
This is what my httpd.conf (the Alias part) looks like:

Alias /PHP /home/luke/PHP
<directory /home/luke/PHP>
    AllowOverride FileInfo Limit Options Indexes
    Order allow,deny
    Allow from all
</directory>

After that, i changed the permissions for the home/luke/PHP-folder to 777 (using chmod). I restarted Xampp and got a 403 when i tried to navigate into http://localhost/PHP

The Apache-Server runs under the http-User (which exists) and the http-Group. So, i added the http-User in my Group (the group luke from my user, using the chown-tool). I restarted the Server, same error.

Here is (a part from) the error_log-file:

[Sun Apr 24 18:05:37 2011] [error] [client 127.0.0.1] (13)Keine Berechtigung: access to /PHP/ denied
[Sun Apr 24 18:10:30 2011] [error] [client 127.0.0.1] (13)Keine Berechtigung: access to /PHP/ denied
[Sun Apr 24 18:10:30 2011] [error] [client 127.0.0.1] (13)Keine Berechtigung: access to /PHP/ denied

So, the Alias I created should work, but what do I need to do to make my /home/luke/PHP-folder accessible to the Apache Server?

I also tried to create a Symlink in the htdocs-folder, but that didn't work neither.

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

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

发布评论

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

评论(2

弥繁 2024-11-10 16:18:24

Apache 需要能够:

  • 从 /home/luke/PHP 目录读取——您已经允许这样做,显然
  • 遍历该目录的父目录。

通常,您必须在您的主目录上向其他人授予执行权限(这意味着他们将能够遍历该目录,转到其子目录)

chmod o+x /home/luke

当然(尤其是在多用户环境中),您必须确保其他用户无法访问您的其他目录和文件 - 通常通过删除组< /code> 和 other 可能位于您的主目录下的目录/文件中。

Apache needs to be able to :

  • Read from your /home/luke/PHP directory -- you already allowed that, aparently
  • Traverse the directories which are parents of that directory.

Typically, you'll have to give the execution permission to others (which means they'll be able to traverse that directory, to go to its children), on your home directory :

chmod o+x /home/luke

Of course (especially in a multi-user environment), you'll then have to make sure that other users cannot access your other directories and files -- typically by removing all privileges that group and other could have on directories/files under your home directory.

国粹 2024-11-10 16:18:24

我通过配置如上所示的别名来解决我的问题,但将 Apache 的用户设置为我的用户(“luke”)并保留组:

# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
User luke
#Group http

之后我更改了 htdocs 的所有者 - 和PHP-我的用户(luke)的目录并重新启动 LAMPP。

现在一切正常。还要感谢 Pascal MARTIN 和 hornetbzz!

I fixed my issue by configuring the Alias like shown above, but setting the Apache's user to my user ("luke") and leaving the Group out:

# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
User luke
#Group http

After that I changed the owner of the htdocs- and the PHP-Directory to my user (luke) and restarted LAMPP.

Now everything works fine. Also thanks to Pascal MARTIN and hornetbzz!

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