Deploying websites in different PHP versions on Runcloud using Capistrano

I have a DigitalOcean server with RunCloud on it, using PHP 7.4 as the default PHP version. As you might know, RunCloud can run applications using different PHP versions but the php command will always use the default version.

Since Capistrano always uses the default php and composer commands you'll need to do some minor tweaks in order to deploy a new PHP 8 website.

This is the command for running a specific PHP version on RunCloud:

/RunCloud/Packages/php80rc/bin/php -v

Then, to run Composer using that version you'll need to run this:

/RunCloud/Packages/php80rc/bin/php /usr/sbin/composer install

To make Capistrano run the Composer like this simply add this to your config/deploy.rb file:

SSHKit.config.command_map[:composer] = "/RunCloud/Packages/php80rc/bin/php /usr/sbin/composer"

Finally, because the Symfony plugin also executes some PHP commands such as bin/console cache:warmup the php command should also be replaced:

SSHKit.config.command_map[:php] = "/RunCloud/Packages/php80rc/bin/php"

That's all there is to it!

Did you notice you didn't have to accept any ugly cookie policy popup? That's because I got rid of Google Analytics and moved to Fathom, a simplistic, privacy-focused (and amazing) analytics tool !