[Linux] Let's talk about when I stumbled upon a symbolic link I was using.

Contents

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

environment

What is a symbolic link?

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.

Practice

things to do

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.

Command operation

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!

Summary

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.

Reference

Recommended Posts

[Linux] Let's talk about when I stumbled upon a symbolic link I was using.
What I stumbled upon when using CodeIgniter on a Linux server
I stumbled upon using MoviePy, so make a note
What I stumbled upon using Airflow
A note I was addicted to when making a beep on Linux
It was dangerous to specify a relative path when generating a symbolic link
A memo that I stumbled upon when doing a quote RT on Twitter Bot
Summary of linux command techniques that I knew when I was a fledgling engineer
Linux Ubuntu16.04 I got a little scary error when I ran a command using sudo
[Linux] Symbolic link
A story that was convenient when I tried using the python ip address module
The story when I was using IntelliJ on Linux and could not input Japanese
What I did when I stumbled on a Django tutorial
SoC FPGA: A small story when using on Linux
What I was addicted to when using Python tornado
I stumbled upon PyUnicodeUCS4_FromStringAndSize when inserting TensorFlow with pip
A note of what I learned when I thought about using pyenv or virtualenv on Windows
What I was addicted to when dealing with huge files in a Linux 32bit environment
A story that stumbled when I made a chatbot with Transformer
What I was careful about when implementing Airflow with docker-compose
I got a Value Error when using JUMAN ++ with PyKNP
[Linux] A story about mounting a NAS through a firewall using NFS
Add "/" at the end when completing a directory symbolic link
I stumbled when I tried to install Basemap, so a memorandum
What I was asked when using Random Forest in practice
What I was worried about when displaying images with matplotlib
When I tried to scrape using requests in python, I was addicted to SSLError, so a workaround memo