简体   繁体   English

如何在Xampp for OSX中设置符号链接

[英]How to setup symlink in xampp for osx

I'm failing to setup a symlink within a site directory of my xampp install on osx. 我无法在osx上的xampp安装的站点目录内设置符号链接。 I am inexperienced with both apache and symlinking, but I'm giving it a go anyway. 我对apache和符号链接都没有经验,但是无论如何我都愿意尝试。

Here's the directory structure I'm trying to achieve: 这是我要实现的目录结构:

htdocs/symlinktest/
    whoami.php
    img/
        test.img.jpg
    app/
        ->img/
            test.img.jpg

The symlink was setup with the following link command: 使用以下链接命令设置了符号链接:

ln -s img app

It appears to be set correctly: 它似乎设置正确:

drwxrwxrwx   3 username  admin   102B Aug 14 16:26 app
    lrwxr-xr-x  1 username  admin     3B Aug 14 16:26 img -> img
drwxrwxrwx   3 username  admin   102B Aug 14 16:17 img
-rwxrwxrwx   1 username  admin    29B Aug 14 23:16 whoami.php

Visiting localhost/symlinktest/ shows a directory index with img and app as subdirectories, and it shows whoami.php. 访问localhost / symlinktest /将显示带有img和app作为子目录的目录索引,并显示whoami.php。 However, localhost/symlinktest/app/ displays an empty directory. 但是,localhost / symlinktest / app /显示一个空目录。

Opening whoami.php in browser displays nobody. 在浏览器中打开whoami.php不会显示任何内容。 Running ls -l in htdocs' parent displays the following for htdocs: 在htdocs的父级中运行ls -l将显示以下htdocs:

drwxrwxr-x@  70 root    admin   2380 Aug 14 16:12 htdocs

Running ls -l in htdocs displays the following for symlinktest: 在htdocs中运行ls -l对symlinktest显示以下内容:

drwxrwxrwx    6 username  admin       204 Aug 14 17:59 symlinktest

and the same is true for the child directories. 子目录也是如此。

I've changed the user setting in httpd.conf in xampp/etc/, so it now has the following user setting: 我已经更改了xampp / etc /中httpd.conf中的用户设置,因此它现在具有以下用户设置:

User nobody
Group admin

it already had the following directive set: 它已经设置了以下指令:

DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Require all granted
</Directory>

I have tried restarting xampp via the xampp control panel, after each change. 每次更改后,我都尝试通过xampp控制面板重新启动xampp。 I have tried chowning the htdocs folder to nobody:admin, while also recursively chowning the symlinktest folder and subdirectories to nobody:admin. 我尝试将htdocs文件夹整理为nobody:admin,同时还递归将symlinktest文件夹和子目录整理为nobody:admin。 Unfortunately I still saw an empty index in symlinktest/app/. 不幸的是,我仍然在symlinktest / app /中看到一个空索引。 Attempting to view test.img.jpg in browser gives me a 403. 尝试在浏览器中查看test.img.jpg会给我403。

I've checked all the accepted answers for similar questions in stackoverflow as well as other sites, but I haven't had any luck. 我已经检查了所有接受的答案,以便在stackoverflow以及其他站点中找到类似的问题,但是我没有任何运气。

I'm at my wits end, and I'm pretty far behind in getting a deployment strategy in place in time for a project that launches soon. 我精打细算,在为即将启动的项目及时制定部署策略方面,我远远落后于我。 Any help, advice, or redirection would be highly appreciated. 任何帮助,建议或重定向将不胜感激。

(To be clear, the reason for doing this, is to isolate large static file directories away from our repo for faster push/pulls.) (很明显,这样做的原因是将大型静态文件目录与我们的存储库隔离开,以便更快地进行推/拉。)

Big thanks to Bryan Encina for providing the answer over g+. 非常感谢Bryan Encina提供g +的答案。

The answer is, check the details. 答案是,检查详细信息。 I was creating self referencing a symlink. 我正在创建自我引用符号链接。 The way I understood it, the symlink paths were relative to the command, but target should actually be the relative path to the end symlink. 以我的理解,符号链接路径是相对于命令的,但目标实际上应该是指向最终符号链接的相对路径。 So I just needed to set the symlink like this (note the ../ ): 所以我只需要像这样设置符号链接(注意../ ):

ln -s ../img app

I had assumed the issue was with the things I knew the least about rather than simply double checking the details. 我以为问题是我最不了解的事情,而不是简单地仔细检查细节。

Derp. 德普

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

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