Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
410 views
in Technique[技术] by (71.8m points)

laravel - 如何在另一个符号链接目录中创建目录的符号链接?(How to create a symlink of a directory inside another symlinked directory?)

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.

(通过将Laravel网站克隆到与public_html(称为laravel)相同级别的目录,并使用以下命令将指向laravel / public目录的符号链接创建到public_html,从而成功地将Laravel网站部署到Web服务器上: ln -s laravel/public public_html这很好。)

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.

    (我将项目克隆到“ laravel_dev”目录中,该目录与public_html和laravel目录相同。)

  2. I created a public_html/dev directory.

    (我创建了public_html / dev目录。)

  3. Now, I want to create a symlink of 'laravel_dev/public' into 'public_hmtl/dev' and here is where I am having trouble.

    (现在,我想将“ laravel_dev / public”创建为“ public_hmtl / dev”的符号链接,这是我遇到麻烦的地方。)

    If I do ln -s laravel_dev/public public_html/dev It creates a file (not a directory) called public inside public_html/dev.

    (如果执行ln -s laravel_dev/public public_html/dev它将在public_html / dev内部创建一个名为public的文件(而非目录)。)

I tried making the target go to laravel/public/dev, with the same result.

(我尝试使目标进入laravel / public / dev,结果相同。)

I double checked that laravel_dev/public directory exists and it is not empty.

(我再次检查了laravel_dev / public目录是否存在,并且它不为空。)

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.

(我还尝试删除laravel / public / dev中的dev目录,结果是它在laravel / public中创建了一个名为dev的文件,但它不是目录。)

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.

(当执行上述命令时,我位于www目录中。(数字)表示符号链接,而*表示“物理”目录。)

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*)
  ask by jokogarcia translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

(请注意,您的网络服务器也可能存在问题。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...