cancel
Showing results for 
Search instead for 
Did you mean: 

Symbolic Link Nightmare

Symbolic Link Nightmare

I'm afraid I stepped on my own 'appendage' when I took a Magento 2 dev site and simply moved all of the files from the 'dev' directory to the 'live' directory on the same server. Then after we took the site out of maintenance mode I ended up with a blank page with error logs full of unresolved symbolic links. So I performed a 'shortcut', I copied the entire live site to the dev site directory as a 'temporary' fix. Of course this has to be resolved permanently, but I had no idea that there were 1000 +/- symlinks that were affected. So the question is, is there a programmatic way of changing for example the following:

 

current symlink name:
/var/www/vhosts/website.com/httpdocs/pub/static/frontend/Magento/luma/en_US/jquery.js

current symlink target:

/var/www/vhosts/website.com/dev.website.com/lib/web/jquery.js

 

change to target:

/var/www/vhosts/website.com/httpdocs/lib/web/jquery.js

 

in a shell script?

 

So I need to find all symlinks that have as part of their target:

/var/www/vhosts/website.com/dev.website.com/........

 

to: 

/var/www/vhosts/website.com/httpdocs/......

2 REPLIES 2

Re: Symbolic Link Nightmare

M2 does have symbol link files since m2.0.1. I had the same experience with sackerman ever. What you can do is create a separate dev server with same file structure as production server. So the symbol link will work after you copy or move files.

 

You can use find to list all symbol link files. I remember that is a large number. It will take you long time to modified them one by one.

 

I suggest M2 stop symbol link files but copy duplicated files directly. Anyway hard disk is not so expensive as before. And tiny css, js, php files will not take too much disk space.

------ BrianC on M2

Re: Symbolic Link Nightmare

Well, I discovered that all symlinks were in the '/pub/static/frontend/' subdirectory structure, so I just needed to delete all of the folders and re-run the static content deploy command. I guess it pays to 'think' before panicking ;-)