1

Apologies in advance for any rookie errors on my part... I'm a PC user recently thrust into the world of Macs via new job...

Running OS X Yosemite 10.10.5 PHP version 5.5.27 Apache version 2.4.16 (Unix)

I've been attempting to set up and run localhost for developing websites locally. I have done this successfully once - localhost itself is running with no issues.

The problem has come in when trying to create a symbolic link between the sites folder used by localhost, and where the site files are actually stored (this location cannot be changed).
(I'm also aware of the bad practice with spaces in filenames, but these sites are already created)

I followed the instructions in this tutorial, all the way through with no issues at first. http://ole.michelsen.dk/blog/setup-local-web-server-apache-php-osx-yosemite.html

I have ONE site set up and working with a symlink created using ln -s '~/Dropbox/Shared Sites/SITENAME ~/Sites/SITENAME’ No problems at all here (SITENAME being the directory the site files are in)

However, I am now attempting to add a second site. Using the command above, the terminal becomes unresponsive. A > is added to the next line, but it appears no commands are run (the symlink does not work). I can type but no commands are executed. Pressing CTRL+C returns the terminal to the previous state where it will accept commands again. All other commands seem to run correctly.

I have verified that the directory exists, and am able to cd to it. I have also tried running ln -s '/SITENAME ~/Sites/SITENAME’ when in the parent folder, with the same result. I have also tried running the command with sudo

I have also tried downloading and using iTerm, with the same result.

Have also attempted to create a symlink for a 3rd/separate site, same again.

Can anyone shine any light on why this command seems to have ceased to function when previously working, and how to either fix or work around this to add additional sites to localhost?

Thanks :)

  • I think you're using apostrophes where they are not required, are not helpful, and, in fact, are harmful. Try running without those apostrophes. – TOOGAM Oct 20 '15 at 11:03
  • @TOOGAM - Awesome, thank you - weirdly, it worked with the apostrophes previously - it doesn't work just with the apostrophes removed (because of the spaces in the filenames...) - but I just tried escaping the spaces with \ and it seems to be working now! So I used ln -s ~/Dropbox/Shared\ Sites/SITENAME ~/Sites/SITENAME (in case anyone else comes across this in future) – Roxy Walsh Oct 20 '15 at 14:42
0

For the sake of clarity for anyone else who might have the same problem (I can't be the only one, right? :S ):

With thanks to @TOOGAM - the solution has been to remove the apostrophes/quotes and instead, escape the spaces with a \ - so the command which is now working is

ln -s ~/Dropbox/Shared\ Sites/SITENAME ~/Sites/SITENAME

Still no wiser as to why it originally worked with the apostrophes, but problem solved all the same! :)

| improve this answer | |
0

To anyone else joining in, see also the answer that Roxy Walsh posted, which provides some additional details about the problem, which are needed to understand some of the details provided by my answer.

Okay, here's the deal:
The apostrophes were escaping the tildes.

Try this:

echo ~
echo '~'

What you'll find is that the first command expands the ~ to your home directory. In the second command, you get an actual tilde. The tilde was "escaped". Escaping means to specify that the character needs to be treated like a normal character, instead of having a special meaning.

Now, what you needed to do is to escape the spaces, which you did with backslashes, but to not escape the tilde. Spaces typically have a special meaning, which is to separate your parameters. You don't want that separated: your space in "Shared Sites/" is all part of one directory. That particular space is not intended to tell the "ln" command that you're done specifying the first file/directory, and are about to specify the next file/directory. So that space needed to be escaped.

Based on the example you showed, the following would also have worked:

ln -s ~/'Dropbox/Shared Sites/SITENAME' ~/Sites/SITENAME

| improve this answer | |
  • That makes a lot of sense, thanks for the detailed explanation! :) – Roxy Walsh Oct 21 '15 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.