As the title suggests, I used to use symlinks in Laravel, but when I deployed it to the production environment, the symlinks I had set in the local environment disappeared. First of all, I stumbled in the production environment because I used it without understanding symbolic links very much at the local stage. By the way, the method of specifying the symbolic link at the time of local is as follows. Reference: https://readouble.com/laravel/6.x/ja/filesystem.html
Symbolic link is one of the functions of the file system of the operating system (OS), and it is a mechanism to create another file that points to a specific file or directory and refer to the main body through it. Quote
Yeah, that's true, but it's hard to understand. When I interpreted it in my own way It means that you will create a folder inside the folder and that folder will automatically jump to the specified link destination. Now that you have an overview, let's actually create it.
In Laravel, there are img, css, js folders in the public folder respectively, and I think that images, css files, and js files will be put in each. When you want to extract an image from there, you specify the hierarchy and fetch it. Therefore, if you create a folder that specifies a symbolic link in the public folder and specify that folder, it will automatically jump to the link destination, so you can retrieve the image of the link destination.
By the way, I am in a local environment
php artisan storage:link
I did not understand it because I specified it without thinking and moved it.
Therefore, this time I will describe how to specify directly in linux.
ln -s [Link destination] [Folder storage]
//Example
ln -s /var/www/test/storage/ /var/www/test/public
If you specify the command like this, you can create it!
The above is the content related to symbolic links. After all, if you don't understand well, you will stumble somewhere. Lol The articles that I referred to are as follows.
Recommended Posts