[LINUX] [Ln] How to paste a symbolic link in a directory is complicated

When deploying a project to a server, I wanted to put only the public folder in the document root.

Thing you want to do

Suppose you have a tree that looks like this.

root
├── project
│   ├── etc
│   └── public
│       ├── index.html
│       ├── css
│       └── js
└── public_html
    └── project

What I want to do is /root/public_html/project To /root/project/public Link to

public_html
    └── project
        ├── index.html
        ├── css
        └── js

The state that looks like.

Create a symbolic link with the ln command

Failure

$ cd /root/public_html
$ ln -s /root/project/public project

result

$ ls -l
drwx---r-x project

There is no link.

$ cd project
$ ls -l
lrwxrwxrwx public -> /root/project/public

/root/public_html/project There is a link called public under. Since it is a failure, erase it once.

$ rm public

Link the contents of the directory

With / *, all the files under it challenge again.

$ cd /root/public_html

$ ln -s /root/project/public/* project

$ ls -l
lrwxrwxrwx index.html -> /root/project/public/index.html
lrwxrwxrwx css -> /root/project/public/css
lrwxrwxrwx js -> /root/project/public/js

did it.

With this method, /root/public_html/project The link is attached after the directory called is an entity. So /root/public_html/project I was angry when I tried to do this without it.

Link the directory itself

Delete the existing directory once.

$ pwd
/root/public_html

$ rm -rf project
$ ln -s /root/project/public project

$ ls -l
lrwxrwxrwx project -> /root/project/public

This is also a link. Here, the project itself becomes a link.

Summary

When I tried it on a rental server, when I tried "linking the directory itself", it was overwritten by an empty directory later. It seems that a directory with a domain (subdomain) name is automatically created in the server settings, so was it overwritten without being recognized as a directory?

So this time Adopted the method of "linking the contents of the directory".

I think it's used properly depending on the time and the case.

Recommended Posts

[Ln] How to paste a symbolic link in a directory is complicated
How to put a symbolic link
How to read a file in a different directory
How to get a stacktrace in python
How to use is and == in Python
How to clear tuples in a list (Python)
How to create a JSON file in Python
How to implement a gradient picker in Houdini
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
How to write a named tuple document in 2020
How to count numbers in a specific range
How to Mock a Public function in Pytest
How to get a list of files in the same directory with python
How to specify a schema in Django's database settings
How to convert / restore a string with [] in python
How to know the current directory in Python in Blender
How to use a library that is not originally included in Google App Engine
How to list files under the specified directory in a list (multiple conditions / subdirectory search)
[Python] How to expand variables in a character string
A memorandum on how to use keras.preprocessing.image in Keras
How to use any or all to check if it is in a dictionary (Hash)
Convert a path string that uses a symbolic link in the middle to an absolute path
How to display DataFrame as a table in Markdown
How to change static directory from default in Flask
How to check in Python if one of the elements of a list is in another list
How to execute a command using subprocess in Python
How to reference static files in a Django project
[Linux] How to put your IP in a variable
What is the difference between a symbolic link and a hard link?
How to test that Exception is raised in python unittest
[Ubuntu] How to delete the entire contents of a directory
How to slice a block multiple array from a multiple array in Python
How to import NoteBook as a module in Jupyter (IPython)
How to output a document in pdf format with Sphinx
A story about how to specify a relative path in python.
How to use the __call__ method in a Python class
How to import a file anywhere you like in Python
How to specify a public directory Python simple HTTP server
How to temporarily implement a progress bar in a scripting language
How to mount a Windows 10 directory on Ubuntu-Server 20.04 on VMware Workstation 15
How to define multiple variables in a python for statement
A note on how to load a virtual environment in PyCharm
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
How to generate a query using the IN operator in Django
How to check if a value exists in an enum
How to get the last (last) value in a list in Python
How to get a list of built-in exceptions in python
How to import NoteBook as a module in Jupyter (IPython)
How to get a quadratic array of squares in a spiral!
How to call a function
How to hack a terminal
How to develop in Python
How to trick and use a terrible library that is supposed to be kept globally in flask
How to display a specified column of files in Linux (awk)
How to paste a CSV file into an Excel file using Pandas
[sh] How to store the command execution result in a variable
How to determine the existence of a selenium element in Python
How to pass arguments to a Python script in SPSS Modeler Batch