2

I succesfully deployed a Laravel website onto a web server by cloning it into a directory at the same level as public_html (called laravel) and creating a symlink to the laravel/public directory into public_html, with this command: ln -s laravel/public public_html This works great.

Now I want to have a "test" version of the site for development, and I wanted to do the same.

  1. I cloned my project in a "laravel_dev" directory, same level as public_html and laravel directories.
  2. I created a public_html/dev directory.
  3. Now, I want to create a symlink of 'laravel_dev/public' into 'public_hmtl/dev' and here is where I am having trouble. If I do ln -s laravel_dev/public public_html/dev It creates a file (not a directory) called public inside public_html/dev.

I tried making the target go to laravel/public/dev, with the same result. I double checked that laravel_dev/public directory exists and it is not empty. I also tried removing the dev directory inside laravel/public/dev, and the result there is that it creates a file called dev inside laravel/public but it is not a directory.

To clarify, my directory tree is something like this:

www
|___public_html(1)/dev
|___laravel/public(1*)/dev
|___laravel_dev/public

I am positioned in www directory when I am executing the mentioned commands The (number) indicates symlink and the * indicates the "physical" directory. Using this notation here is what I want to acomplish:

www
|___public_html(1)/dev(2)
|___laravel/public(1*)/dev(2)
|___laravel_dev/public(2*)
cinnaroll45
  • 2,661
  • 7
  • 24
  • 41
jokogarcia
  • 163
  • 2
  • 11

1 Answers1

1

You should just make link in the physical directory.

mkdir laravel{,_dev}
ln -s laravel public_html
ln -s ../laravel_dev laravel/dev

It gives me following directory/files tree

[Alex@Normandy so]$ tree
.
├── laravel
│   └── dev -> ../laravel_dev
├── laravel_dev
└── public_html -> laravel

Simple test:

[Alex@Normandy so]$ echo "test dev" > laravel_dev/test
[Alex@Normandy so]$ cat public_html/dev/test 
test dev

Note that there might be also problem with your webserver.

Alex Baranowski
  • 1,014
  • 13
  • 22
  • I'm sorry. I don't quite follow your answer. Why do you use "../" in the second command? Did you change directories and skiped that step? – jokogarcia Dec 02 '19 at 10:47
  • It's just the way ln -s works. Imagine that you are `laravel/dev` softlink. Then the `laravel_dev` directory from your point of view is `../laravel_dev`. Softlinks supports both absolute and relative paths. – Alex Baranowski Dec 02 '19 at 14:23