已启用Nginx网站的网站可用:无法在Ubuntu 12.04中创建配置文件之间的软链接 [英] Nginx sites-enabled, sites-available: Cannot create soft-link between config files in Ubuntu 12.04

查看:139
本文介绍了已启用Nginx网站的网站可用:无法在Ubuntu 12.04中创建配置文件之间的软链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在包含/etc/nginx/中启用了站点的服务器块和可用站点的目录中的服务器块的配置文件之间创建软链接.

I am trying to create soft links between config files containing server blocks in the sites-enabled and sites-available directories in /etc/nginx/.

我正在使用的命令是:

sudo ln -s sites-available/foo.conf sites-enabled/

然后执行时:

ls -l

结果是:

lrwxrwxrwx 1 parallels parallels 27 Aug  6 20:44 immigrationinformation.conf -> immigrationinformation.conf

其中immigrationinformation.conf -> immigrationinformation.conf部分的木炭带有红色字体.

where the immigrationinformation.conf -> immigrationinformation.conf part has a charcoal with red typeface.

然后我尝试访问此软链接时,被告知它已断开.

When I then try and access this soft-link, I am told that it is broken.

当我在可通过网站访问的目录中创建软链接时

When I create the soft-link in the sites-available directory i.e.

sudo ln -s sites-available/foo.conf sites-available/foo_link.conf

它正常工作.但是,如果我随后将其移至启用了站点的目录,则该链接将再次断开.

it works as normal. However, if I then move this to the sites-enabled directory, the link is broken again.

我可以通过文件管理器GUI创建软链接,但不能通过命令行创建.我也可以毫无问题地创建硬链接.

I can create the soft link via the file manager GUI but not via the command line. I can also create hard-links with no problem.

我怀疑这是一个权限问题,因此我尝试将目录和目录本身的所有权限都设置为777,并将所有者更改为除root之外的其他权限,但仍然没有运气.

I suspected it was a permissions issue so I have played around with setting all permissions to 777 of both directories and the directories themselves and also changing the owners to something other than root, but still with no luck.

任何帮助,我都会非常感激,谢谢.

Any help would me much appreciated, thank you.

推荐答案

您首先需要了解符号链接的目标是路径名.并且它可以是绝对的,也可以相对于包含符号链接的目录

You need to start by understanding that the target of a symlink is a pathname. And it can be absolute or relative to the directory which contains the symlink

假设您在可用的站点中拥有foo.conf

Assuming you have foo.conf in sites-available

尝试

cd sites-enabled
sudo ln -s ../sites-available/foo.conf .
ls -l

现在,您将在启用了站点的foo.conf中有一个符号链接,该链接有一个目标../sites-available/foo.conf

Now you will have a symlink in sites-enabled called foo.conf which has a target ../sites-available/foo.conf

需要明确的是,Apache的常规配置是潜在站点的配置文件位于可用站点中,而已启用站点的符号链接位于可用站点中,指向可用站点中的目标.描述设置的方式似乎并非如此,但这不是您的主要问题.

Just to be clear, the normal configuration for Apache is that the config files for potential sites live in sites-available and the symlinks for the enabled sites live in sites-enabled, pointing at targets in sites-available. That doesn't quite seem to be the case the way you describe your setup, but that is not your primary problem.

如果要始终将指向同一文件的符号链接指向同一文件,则无论符号链接位于何处,目标都应为完整路径.

If you want a symlink to ALWAYS point at the same file, regardless of the where the symlink is located, then the target should be the full path.

ln -s /etc/apache2/sites-available/foo.conf mysimlink-whatever.conf

以下是我的ls -l/etc/apache2/sites-enabled的输出(的第1行):

Here is (line 1 of) the output of my ls -l /etc/apache2/sites-enabled:

lrwxrwxrwx 1 root root  26 Jun 24 21:06 000-default -> ../sites-available/default

查看符号链接的目标如何相对于包含符号链接的目录(以".."开头的意思是向上一个目录).

See how the target of the symlink is relative to the directory that contains the symlink (it starts with ".." meaning go up one directory).

硬链接完全不同,因为硬链接的目标不是目录条目,而是文件系统Inode.

Hardlinks are totally different because the target of a hardlink is not a directory entry but a filing system Inode.

这篇关于已启用Nginx网站的网站可用:无法在Ubuntu 12.04中创建配置文件之间的软链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆