[Drupal] How to create a local installation of a Drupal multisite project connected through symlinks?
As a Drupal developer you might have come across a Drupal multisite installation in which the different sites were connected through symlinks. As a developer you often need to create a local installation of a live Drupal project to make the required changes before pushing it to the live version of a site. If you are facing the same situation in your Drupal site and would like to know how to create a local installation of a Drupal multisite project connected through symlinks then continue reading to know more.
We got a chance to work on a maintenance project running on Drupal. The corresponding server had 3 sites in it. Nevertheless we had to modify only a single site. When I checked the Drupal site thoroughly, I found that these 3 sites were using the same database and the same Drupal files. However the themes were different for each site, which were maintained in settings.php. When I probed deeper, I found that only one of the projects had the full Drupal installation and others were simply a symlink of the first one.
If you want to know more about symlinks checkout PHP Symlink. Now that I knew about the complete details of the server, the next step I took was to create a local setup for the site to do the maintenance work. The steps I took were as follows
Steps
- Downloaded the server files to localhost(var/www).
- Created a new directory in which I intended to complete the maintenance tasks.
- Created a symlink of the original folder to the newly created directory using the command
ln -s /var/www/[original drupal installation folder] /var/www/[newly created folder].
- After step3, my newly created folder had the complete details of the original folder.
By creating a virtual host pointing to my newly created folder, I was able to do the necessary maintenance tasks effortlessly.