I have a few old Drupal 7 websites that are no longer available online. I need to continue showcasing these sites in my portfolio, but found that the Wayback Machine didn’t capture them as well as I had hoped.
With the Wayback Machine out of the picture, I needed to create my own archive of these sites. However, with Drupal 7 fully discontinued—and the required Drush and PHP versions years out of date—I couldn’t easily spin up and update these sites to capture a static archive.
PHP versions were not an issue on my server. HestiaCP provides tooling that enables users to install (inadvisably) the oldest version of PHP that Drupal 7 supports: PHP 5.6.
The lack of a version of Drush on my server that was compatible with both Drupal 7 and newer PHP versions was particularly problematic for resurrecting these sites. I couldn't simply install Drush 8 the traditional way as the drush
command already existed on the server, as it was set up to act as a launcher for projects that include Drush as a Composer dependency. I needed to install Drush in such a way that a user could specify the version as part of the command, ideally named something like drush8
, leaving the drush
command to function as the default for the launcher.
Installing Drush Under a Different Alias
If your command line’s default PHP version is compatible with the Drush version you wish to install, creating a separate alias is straightforward. All you need to do is change the name of the drush.phar
file to something other than "drush" when you copy it into the local binary directory.
Download the
drush.phar
file of the version of Drush you wish to install under a different alias from the Drush GitHub repository's releases page.📝 Note
The last major release version of Drush to include adrush.phar
file is Drush 8. All later versions of Drush must be installed via Composer, which is not covered in this guide.Test the install by running the command:
php drush.phar core-status
ℹ️ If this doesn’t work due to PHP errors, continue to the next section to learn how to install Drush under a different alias with a specific PHP version.
Make
drush.phar
executable by running the command:chmod +x drush.phar
Move the
drush.phar
file to the local binary directory (/usr/local/bin
)sudo mv drush.phar /usr/local/bin/drush8
- The command
drush8
will now run Drush 8.
Installing Drush Under a Different Alias and Specific PHP Version
If the Drush version you're trying to install requires a specific PHP version, you can create an alias that also specifies the path to that PHP binary.
Download the
drush.phar
file of the version of Drush you wish to install under a different alias from the Drush GitHub repository's releases page.📝 Note
The last major release version of Drush to include adrush.phar
file is Drush 8. All later versions of Drush must be installed via Composer, which is not covered in this guide.Test the install by running the command
php7.4 drush.phar core-status
ℹ️ If you encounter PHP errors, check the PHP compatibility for your chosen Drush version and ensure that PHP version is installed on your system. Then, adjust the command to use the appropriate PHP alias (e.g.
php5.6
,php7.0
,php8.0
, etc.).Get the path to the PHP binary that allowed
drush.phar
to run successfullywhich php7.4
This will return the path to the PHP binary. Note this path for use in an upcoming step.
Move the
drush.phar
file to a permanent location such as the add-on applications directory (/opt
)sudo mkdir -p /opt/drush8 sudo mv drush.phar /opt/drush8/drush.phar
Create a wrapper script for this Drush version by making a new file at
/usr/local/bin/drush8
with the following:#!/bin/bash /usr/bin/php7.4 /opt/drush8/drush.phar "$@"
Make the wrapper executable
sudo chmod +x /usr/local/bin/drush8
- Now you can run Drush 8 using PHP 7.4 by executing the command
drush8
.