符号链接和 LAMPP htdocs

符号链接和 LAMPP htdocs

我完成了这些步骤以便创建一个在 lampp htdocs 之外使用的符号链接目录。

$ mkdir test
$ chmod 777 test
//test is now in /home/Dropbox/test/
//I put an index.html with 777 perms in it.
$ cd /opt/lampp/htdocs/
$ sudo ln -s /home/Dropbox/test/ /opt/lampp/htdocs/$USER
//my user appears as symlink directory in htdocs.
$ /opt/lampp/lampp stop
$ /opt/lampp/lampp start
//lampp is now restarted

我输入 localhost/我的用户名并出现 404 错误...未找到对象。

请注意,我可以在 htdocs 目录中创建常规目录和 .html/.php 文件,但无法创建任何符号链接目录或 .html/.php 文件,它们将无法加载。

感谢您的输入!

httpd conf(仅涉及 SymLinks 的部分)

<Directory />
    Options FollowSymLinks
    AllowOverride None
    #XAMPP
    #Order deny,allow
    #Deny from all
</Directory>

<Directory "/opt/lampp/htdocs/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    #Options Indexes FollowSymLinks
    # XAMPP
    Options Indexes FollowSymLinks ExecCGI Includes


    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    # since XAMPP 1.4:
    AllowOverride All


    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>



错误日志

$ tail -f error_log 
[Fri Dec 23 13:55:50 2011] [error] [client 127.0.0.1] Symbolic link not allowed or link target not accessible: /opt/lampp/htdocs/*myusername*
[Fri Dec 23 13:56:02 2011] [notice] caught SIGTERM, shutting down
[Fri Dec 23 13:56:08 2011] [notice] suEXEC mechanism enabled (wrapper: /opt/lampp/bin/suexec)
[Fri Dec 23 13:56:08 2011] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Dec 23 13:56:08 2011] [warn] RSA server certificate CommonName (CN) `localhost' does NOT match server name!?
[Fri Dec 23 13:56:08 2011] [notice] Digest: generating secret for digest authentication ...
[Fri Dec 23 13:56:08 2011] [notice] Digest: done
[Fri Dec 23 13:56:09 2011] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Fri Dec 23 13:56:09 2011] [warn] RSA server certificate CommonName (CN) `localhost' does NOT match server name!?
[Fri Dec 23 13:56:09 2011] [notice] Apache/2.2.21 (Unix) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0c PHP/5.3.8 mod_apreq2-20090110/2.7.1 mod_perl/2.0.5 Perl/v5.10.1 configured -- resuming normal operations



访问日志

$ tail -f access_log 
127.0.0.1 - - [23/Dec/2011:13:41:27 -0500] "GET /work HTTP/1.1" 403 1111
127.0.0.1 - - [23/Dec/2011:13:41:27 -0500] "GET /work HTTP/1.1" 403 1111
127.0.0.1 - - [23/Dec/2011:13:41:28 -0500] "GET /work HTTP/1.1" 403 1111
127.0.0.1 - - [23/Dec/2011:13:55:47 -0500] "GET / HTTP/1.1" 302 -
127.0.0.1 - - [23/Dec/2011:13:55:47 -0500] "GET /xampp/ HTTP/1.1" 200 588
127.0.0.1 - - [23/Dec/2011:13:55:47 -0500] "GET /xampp/head.php HTTP/1.1" 200 1362
127.0.0.1 - - [23/Dec/2011:13:55:47 -0500] "GET /xampp/navi.php HTTP/1.1" 200 2290
127.0.0.1 - - [23/Dec/2011:13:55:47 -0500] "GET /xampp/start.php HTTP/1.1" 200 786
127.0.0.1 - - [23/Dec/2011:13:55:47 -0500] "GET /favicon.ico HTTP/1.1" 200 30894
127.0.0.1 - - [23/Dec/2011:13:55:50 -0500] "GET /work HTTP/1.1" 403 1111



/opt/lampp/htdocs/ 的权限

drwxr-xr-x 4 无人 root 4096 2011-12-23 13:32 htdocs



/opt/lampp/htdocs/*myusername* 的权限

lrwxrwxrwx 1 根 根 39 2011-12-23 13:12我的用户名



/home/Dropbox/test/ 的权限

drwxr-xr-x 2 工作 工作 4096 2011-12-23 13:10我的用户名

答案1

这表明节中不存在 FollowSymLinks。以下是取自这里

<Directory /usr/local/httpd/htdocs>
Options Indexes FollowSymLinks
</Directory>

等待验证 apache 配置(我认为您应该粘贴),这是最有可能的答案。

编辑:在阅读了您对 embobo 的回复后,我去在我的服务器上复制了该问题:

[Fri Dec 23 23:03:58 2011] [error] [client 192.168.15.20] Symbolic link not allowed or link target not accessible: /var/www/html/testsym

我建议对测试的父级进行以下设置

chmod go+x /home/Dropbox

这样 Dropbox 目录就可以对群组和其他人具有执行权限。

答案2

嗯,我不确定该包的默认设置 - 但通常,出于安全原因,Apache 默认禁用符号链接跟踪。

将其添加到您的配置中,在适用于符号链接所在位置的上下文中:

Options +FollowSymLinks

相关内容