0

I'm trying to go through the process of changing a symlink on ubuntu 14.04 LTS without breaking anything. Do I simply rename the folder and change the way the virtual hosts file points to the directory? In order to avoid running into a bunch of problems and breaking the server, I'm wondering if anyone has done this moothly before?

Wolfpack'08
  • 101
  • 2

2 Answers2

0

I was looking to rename all the link that contain a given folder name that im going to rename.

So my intent is to propagate the renaming to all symlink target path pointed there.

I created renamer.sh with this code:

#!/bin/bash

where=$1
what=$2

# find the link with folder having given name
find $where -type l -ilname */*$what*/* 2>/dev/null

# give the target path of each listed link
find $where -type l -ilname */*$what*/* 2>/dev/null | xargs readlink

I wanted to look from / , passing the folder name i want to change being at closer parent folder, so first argument /, second argument :

./renamer.sh / <foldername>

The first find command returns the fullpath of found symlinks.

Then the second find command pipes all the found fullpathes into command readlink that returns the where those symlinks are targeted to.

...

coding a bit more the batch renaming is near...

...

P.S: From Debian 10 Buster I needed to install "readlink" and "findutils"

sudo apt install readlink findutils

Bye

Enrico
  • 1
  • 1
0

Is the symlink you are trying to change the root folder of your web server? If so, then yes, just create a new folder and point your virtualhost to it.

  • Yeah. I changed domain names, so I want to rename the root folder to a domain-specific one. – Wolfpack'08 Feb 03 '16 at 01:13
  • Just rename it then, and then change the new path in your documentroot setting in virtualhost....reload apache and the change should take place...no downtime either. – Nelson Amaya Feb 03 '16 at 01:15
  • I hate to ask, but I'm super new to running a server. Can you tell me which directory (sites-active or sites-enabled) to edit my file in? And it's just editing that one file, nothing else? – Wolfpack'08 Feb 03 '16 at 01:21
  • What Linux distribution are you using? In Ubuntu, the virtual hosts files are located at /etc/apache2/sites-available take a look at this https://forevergeeks.com/host-multiple-websites-from-ubuntu-using-apache#Setting_up_the_VirtualHosts_ – Nelson Amaya Feb 03 '16 at 01:24