Recently I started setting my websites up with this symlink structure that I absolutely love. This setup allows me to quickly switch between versions of Drupal, so when there is an update, I could quickly revert to the previous install if something breaks horribly. This may not be as necessary with the latest developments in Drush, however, if you are using an installation profile, this could be very usefull as you update and check for bugs.
Before doing anything, you want to make sure that you have backed up your database and your original files. The commands below will be used through terminal with SSH access to the site and will assume that you have Drush installed for quick-and-easy downloading.
After you've backedup your entire site, you can begin to implement the symlinks. The first part begins by downloading the SAME version as your Drupal installation. For example, if you are currently using an old verison, like Drupal 7.0, you want to download that version. Simply typing 'drush dl drupal' will download the latest version, so make sure you know which version you are downloading.
1. Go 1 step above your public_html (www) folder and download your current version of Drupal
drush dl drupal-7.0
This will add a folder of the same name (drupal-7.0/) that contains your Drupal installation for that version.
2. Now we will create a symlink for the word drupal. Later on, when you update your site, this symlink will be the only one you will need to update.
ln -s drupal-7.0 drupal
If you do an ls command, you will see the drupal folder like this: drupal@ - But if you do an ls -al to show more details, you will see drupal -> drupal-7.0 which indicates which folder the symlink is going to.
At this point, we would update any contributed modules to make sure the updates work before proceeding to the symlink setup.
3. Next, we move to the public folder and delete the unnecessary .txt files. We also copy the robot.txt file from the downloaded drupal installation in the same command. If the robot.txt file has been edited, make sure you transfer those changes after the file is updated.
cd public_html/
rm *.txt && cp -p ../drupal/robot.txt ./
4. Replace the .php files with symlinks
rm cron.php && ln -s ../drupal/cron.php ./
rm index.php && ln -s ../drupal/index.php ./
rm install.php && ln -s ../drupal/install.php ./
rm update.php && ln -s ../drupal/update.php ./
rm xmlrpc.php && ln -s ../drupal/xmlrpc.php ./
5. Replace the folders with symlinks (EXCEPT the sites/ folder where you add your modules and themes)
rm -R includes && ln -s ../drupal/includes ./
rm -R misc && ln -s ../drupal/misc ./
rm -R modules && ln -s ../drupal/modules ./
rm -R profiles && ln -s ../drupal/profiles ./
rm -R scripts && ln -s ../drupal/scripts ./
rm -R themes && ln -s ../drupal/themes ./
6. Backup your .htaccess file and duplicate the file from the referenced Drupal folder.
mv .htaccess .htaccess.old && cp -p ../drupal/.htaccess ./
I usually check my installation, and refresh the site reports page (admin/reports/status) between each step just to make sure I didn't do something horribly wrong. It onlly takes a minute to update your page. Then after completing this process, clear your cache as well to make sure that doesn't change anything.
At this point, you should be looking at a symlinked drupal installation. Go to your Updates page (admin/reports/updates) and check that your modules are all up-to-date. You should see that your core drupal installation is still at the level that you began with. Now let's test the upgrade.
7. Return to the level above your public folder and download the next version of Drupal.
cd ..
drush dl drupal-7.1
This should create a folder by the same name.
8. Change your drupal symlink.
rm drupal && ln -s drupal-7.1 drupal
Now return to your update page and refresh it. You should see that your version of Drupal has just upgraded. Run your update.php to ensure any database updates are completed, test your site, and then repeat steps 7 & 8 until your website is utilizing the most current version. You will find that this is much easier than coping over files, and it allows you to quickly revert back by repeating step 8, only with the previous version of drupal in the case that you get a white screen of death or another error that makes your site unworkable.


Leave A Comment