Running Multiple Different PHP Versions Simultaneously on Ubuntu 24.04

Monday, August 18th, 2025

Running Multiple Different PHP Versions Simultaneously on Ubuntu 24.04

If you need to run multiple different versions of PHP simultaneously on your Ubuntu server, it can be done.  This is needed when you want to host some legacy sites that cannot run with the breaking changes made in the newest versions of PHP (shame on you PHP for doing such nonsense). 

Here's how I did it on an Ubuntu 24.04 server which uses PHP 8.3 by default.  In this example, I have already installed and configured all web server software packages including PHP 8.3.  The EHCP Force installer can do this for you if you don't know how to install and configure everything you need to run your own web server.

Add the ondrej repo and install PHP 5.6 and 7.4:

sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
sudo apt upgrade
sudo apt-get install php5.6 php5.6-fpm php7.4 php7.4-fpm
sudo apt-get install php7.4-mysql php5.6-mysql php5.6-mysqlnd-ms php7.4-gd php5.6-gd php5.6-zip php7.4-zip php7.4-cli php5.6-cli php5.6-mcrypt php7.4-mcrypt php7.4-gettext php5.6-gettext php5.6-mailparse php7.4-mailparse php7.4-imagick php5.6-imagick php5.6-curl php7.4-curl php7.4-xmlrpc php5.6-xmlrpc php5.6-imap php7.4-imap

I then adjusted the fpm php.ini files in the /etc/php/5.6/fpm/ and /etc/php/7.4/fpm directories to use custom settings that I use (optional).  I then edited the FPM pool for each version of PHP in the www.conf file in /etc/php/7.4/fpm/pool.d and /etc/php/5.6/fpm/pool.d directories to listen on a different port than PHP 8.3.  For example, for PHP 7.4, I changed the listen port to 9011.

Then, for the particular website I wanted to run under a different version of PHP, I changed the nginx template to use the corresponding port for the desired PHP FPM version like so:

location ~ \.php$ {
        root {homedir}/httpdocs;
        include fastcgi_params;
        try_files $uri = 404;
        fastcgi_pass   127.0.0.1:9011;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PHP_ADMIN_VALUE "open_basedir={homedir}:/usr/share/php:/usr/share/pear \n upload_tmp_dir={homedir}/phptmpdir \n session.save_path={homedir}/phptmpdir";
        fastcgi_read_timeout 300;
        limit_req zone=one burst=5;
    }    

Restart nginx.  The website you configured to use a specific version of PHP will be using that version now.

Ubuntu: Allow Automatic Updates for Specific Packages Only

Tuesday, June 14th, 2022

Ubuntu: Allow Automatic Updates for Specific Packages Only

If you want to allow Google products and packages to update automatically, follow this guide.

You can also add additional sources that should update automatically following the same process.

This is helpful when using Selenium, WebDriver for Chrome, and Python.  Doing this allows you to always use the most up-to-date version of all of these dependent packages.

Tested in Ubuntu 20.04

Installing Chrome WebDriver (Linux Script)

Wednesday, August 28th, 2019

Installing Chrome WebDriver (Linux Script)

Find out which version of Chrome is installed on your system before running the below commands.  You can find out your chrome version by running the following command:

google-chrome --version

Adjust the version number (replace {VERSION_NUMBER})  in the below commands to match the version installed on your system!!!

sudo -i
cd ~/Downloads
rm chromedriver_linux64.zip
wget -N https://chromedriver.storage.googleapis.com/{VERSION_NUMBER}/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
mv chromedriver /usr/bin/chromedriver
chown root:root /usr/bin/chromedriver
chmod +x /usr/bin/chromedriver

Selenium and other libraries that rely on the Chrome WebDriver should now work properly.

ASP.NET Web API – Accessing Session Information

Monday, August 12th, 2019

ASP.NET Web API – Accessing Session Information

If WebAPI needs access to SESSION information, here's how to do it:

https://stackoverflow.com/questions/9594229/accessing-session-using-asp-net-web-api#answer-17539008 or ARCHIVE

Using JQuery Color Picker and Cookie Plugins to Change Element Background Colors Dynamically Based on User Preference

Sunday, April 21st, 2013

Changing Website Element Colors Dynamically Based on User Preferences

Wouldn't it be cool to dynamically style a website or webpage based on a user's favorite color?  Thanks to several JQuery plugins, it is now possible to do so!  The JQuery Color Picker plugin allows users to select a color based on a color pallete / color wheel similar to those found within photo editing software such as Adobe Photoshop or Corel PaintShop Pro.  The JQuery Color Plugin can darken, lighten, add, multiply, subtract, find color hues, change rgb values, and manipulate colors in all sorts of ways you probably never imagined possible.  The final piece to dynamically styling a page based on a user selected color is to save the picked color's value in a cookie using the JQuery-Cookie Plugin.  When any page loads, you will need to use the document.ready JQuery function to read the cookie and restyle elements as necessary.  If a cookie is not set, the default color can also be specified here. 

Here's a screenshot of the JQuery Color Picker in action:

To load / use the color picker, place this function within the document.ready function:

// Color Picker Loader
    $('#colorpicker').ColorPicker({
    
       color: defaultColor,
         onShow: function (colpkr) {
              $(colpkr).fadeIn(500);
              return false;
         },
         onHide: function (colpkr) {
              $(colpkr).fadeOut(500);
              return false;
         },
         onChange: function (hsb, hex, rgb) {
          var origColor = '#' + hex;
       
          // Set the main div background colors to what was selected in the color picker
              $('#colorpicker').css('backgroundColor', origColor);
          $('#origColor').css('backgroundColor', origColor);
          
          // Set the cookie
          $.cookie("color", '#' + hex, { path: '/' });
          
          // Set the dark and light colors (multi-iterations)
          darkColor = $.xcolor.darken('#' + hex).getHex();
          for (var i = 0; i < iterations; i++) {
            darkColor = $.xcolor.darken(darkColor).getHex();
          }
            
          lightColor = $.xcolor.lighten('#' + hex).getHex();
          for (var i = 0; i < iterations; i++) {
            lightColor = $.xcolor.lighten(lightColor).getHex();
          }
          
          
          // Set the light and dark divs
          $('#darkColor').css('backgroundColor', darkColor);
          $('#lightColor').css('backgroundColor', lightColor);
          
          // Change class attributes
          $('.light').css('backgroundColor', lightColor);
          $('.dark').css('backgroundColor', darkColor);
          $('.pad').css('backgroundColor', origColor);
          
          // Set the border
          $('#colorpicker').css('border-color', darkColor);
          
          
         }
    }); 

Assign a DIV element the ID of "colorpicker" in your HTML file to activate the color picker.    Don't change the "onShow" or "onHide" JQuery sub-functions of the ColorPicker.  When a user chooses a color from the color picker, the color picker "onChange" function is called.  This is where you need to define what should be done with the color the user has picked.  In my example, I call the $.xcolor.lighten and $.xcolor.darken Color Plugin functions to generate a lighter and darker color.  I use then use the color selected, a lighter variant of that color, and a darker variant of that color to style elements appropriately to keep text readable while offering a new color scheme.  As you can see from the code above, I mainly change the css attributes of certain classes, which the elements have been assigned.  What is changed is the backgroundColor and border-color of certain classes based on the three colors that were generated.

To see what other cool things you can do with all of these plugins, check out the links in the first paragraph.  Click here to see a live demonstration of all three plugins in action and download the source for how it all works based on the example discussed above.  The only Javascript file that needs to be changed to experiment with this sample is the "main.js" file within the "js" folder.

I hope this guide helps.  The plugin websites did not provide all of the code needed for a working sample, but luckily, I did the combination work for you.  Go ahead and use my source for anything!  Please comment if you have questions.