Nginx sites-enabled, sites-available: Cannot create soft-link between config files in Ubuntu 12.04

前端 未结 2 698
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 03:50

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

The command I am usin

相关标签:
2条回答
  • 2021-01-30 04:17

    My site configuration file is example.conf in sites-available folder So you can create a symbolic link as

    ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/
    
    0 讨论(0)
  • 2021-01-30 04:31

    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

    Assuming you have foo.conf in sites-available

    Try

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

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

    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
    

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

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

    0 讨论(0)
提交回复
热议问题