Skip to content

Instantly share code, notes, and snippets.

@Climberdav
Climberdav / switch-php-version.rb
Created November 14, 2017 11:00
Plesk Onyx switching php version with backup
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
require 'fileutils'
current = %x[ php -v | awk NR==1'{print $2}' ]
current_short = current[0,3]
versions = Dir.entries("/opt/plesk/php/").select {|f| !File.directory? f}
puts "Actual version is #{current}"
puts "switching php may possible to version #{versions.delete_if{|i|i==current_short}.join(", ")} with symlinks.\n"
puts "Which version switch on?"
prompt = ">"