When deploying a project to a server, I wanted to put only the public folder in the document root.
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.
$ 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
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.
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.
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