.symlink lost its target once reboot the pc

102 views Asked by At

I have one website virtual hosting under xampp apache and using certbot to obtain ssl cert

certbot certonly --webroot --w C:\\xampp\\htdocs\\mysite\\wordpress --d www.mysite.com

After successful obtain It created 4 pem files in C:\Certbox\archive\mysite\ and 4 .smylink(.pem) files in C:\Certbox\live\mysite\ which symlink to those 4 files on archive folder

Heres the problem: Everytime I reboot the pc, those 4 .smylink(.pem) files seems lost its target to those 4 pem files in C:\Certbox\archive\mysite\ and seems to became broken and preventing xampp apache from starting

What I've tried:

  1. Cmd run cd C:\Certbot\live\mysite\ then del cert.pem.symlink and recreate mklink /H cert.pem.symlink C:\Certbot\archive\mysite\cert.pem
1

There are 1 answers

2
Adarsh S On

It seems like the issue you're facing is related to symbolic links being broken after a system reboot. Windows might reset the symbolic links or the paths might change during startup.

One solution is to create a batch script that recreates the symbolic links each time your computer starts up. Here's an example of how you can create a simple batch script:

  1. Open Notepad or any text editor.

  2. Copy and paste the following script into the editor:

    @echo off
    
    set certbot_path=C:\Certbot
    set site_name=mysite
    
    mklink /H "%certbot_path%\live\%site_name%\cert.pem.symlink" "%certbot_path%\archive\%site_name%\cert.pem"
    mklink /H "%certbot_path%\live\%site_name%\privkey.pem.symlink" "%certbot_path%\archive\%site_name%\privkey.pem"
    mklink /H "%certbot_path%\live\%site_name%\fullchain.pem.symlink" "%certbot_path%\archive\%site_name%\fullchain.pem"
    mklink /H "%certbot_path%\live\%site_name%\chain.pem.symlink" "%certbot_path%\archive\%site_name%\chain.pem"
    
    exit
    
  3. Save the file with a .bat extension, for example, recreate_links.bat. Save it to a location of your choice.

To make this script run on startup, you can create a shortcut to it and place the shortcut in the Startup folder.

  1. Press Win + R to open the Run dialog.

  2. Type shell:startup and press Enter. This opens the Startup folder.

  3. Copy the shortcut of your recreate_links.bat script into this folder.

Now, every time your computer starts up, it will execute the batch script and recreate the symbolic links for you.

PS: Adjust the paths in the script if your actual paths are different.

PPS: This has never happened to me as I primarily use a Linux-based System.