简体   繁体   中英

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. I am inexperienced with both apache and symlinking, but I'm giving it a go anyway.

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. However, localhost/symlinktest/app/ displays an empty directory.

Opening whoami.php in browser displays nobody. Running ls -l in htdocs' parent displays the following for htdocs:

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

Running ls -l in htdocs displays the following for 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:

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. I have tried chowning the htdocs folder to nobody:admin, while also recursively chowning the symlinktest folder and subdirectories to nobody:admin. Unfortunately I still saw an empty index in symlinktest/app/. Attempting to view test.img.jpg in browser gives me a 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.

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+.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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