![]() |
|
Guide Run PHP 7.4 on CyberPanel (Ubuntu 24.04): Old PHP Versions with Docker - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CyberPanel (https://adminsforum.com/Forum-cyberpanel) +---- Forum: CyberPanel Guides & Tutorials (https://adminsforum.com/Forum-cyberpanel-guides-tutorials) +----- Forum: CyberPanel PHP & LSPHP Guides (https://adminsforum.com/Forum-cyberpanel-php-lsphp-guides) +----- Thread: Guide Run PHP 7.4 on CyberPanel (Ubuntu 24.04): Old PHP Versions with Docker (/Thread-guide-run-php-7-4-on-cyberpanel-ubuntu-24-04-old-php-versions-with-docker) |
Run PHP 7.4 on CyberPanel (Ubuntu 24.04): Old PHP Versions with Docker - JAY - 11-14-2026 Run PHP 7.4 on CyberPanel (Ubuntu 24.04): Old PHP Versions with Docker (Tested) You have an old site that needs PHP 7.4 (or 5.6, 7.0...), you open Change PHP in CyberPanel, and the oldest version in the list is PHP 8.1. On Ubuntu 24.04 that isn't a bug you can fix with a click: the old packages don't exist for this system. Here's what we found on a CyberPanel 3.0.8 server, and the workaround we tested: run the old PHP in a small Docker container and let your website pass visitors to it. Why the old versions are missing CyberPanel installs PHP from the LiteSpeed package repository. On Ubuntu 24.04 that repository only has PHP 8.1 to 8.5. We asked the package system directly: Code: apt-cache policy lsphp74 lsphp80 lsphp81 lsphp85Code: lsphp56Code: lsphp80Code: lsphp81Code: lsphp85So you have three choices:
A warning first: PHP 7.4 stopped getting security fixes in November 2022. Treat this as a way to keep an old site alive while you update it, not as a permanent home. The container at least keeps the old PHP separated from the rest of your server. Step 1: Check Docker Over SSH as root: Code: docker --versionCode: Docker version 29.1.3Step 2: Start a PHP 7.4 container Make a folder for the old site's files and put a test page in it: Code: mkdir -p /srv/legacy-php74
cat > /srv/legacy-php74/index.php <<'EOF'
<?php echo "Hello from PHP ", PHP_VERSION, " (", php_sapi_name(), ")\n";
EOFCode: docker run -d --name legacy-php74 --restart unless-stopped \
-p 127.0.0.1:8074:80 \
-v /srv/legacy-php74:/var/www/html:ro \
php:7.4-apache
Code: curl http://127.0.0.1:8074/Code: Hello from PHP 7.4.33 (apache2handler)Step 3: Send your domain to the container Create the website in CyberPanel as usual (any PHP version, it won't be used) and get its SSL certificate. Then open Websites → your site → Config → Rewrite Rules, paste this and click Save Rewrite Rules: Code: RewriteEngine On
RewriteRule ^(.*)$ http://127.0.0.1:8074/$1 [P,L]Code: [P]The screenshot shows the rule, and below it the PHP list that stops at 8.1. Opening Code: https://yourdomain.com/Important: which web server we tested this on. Our test server runs LiteSpeed Enterprise, where a Code: [P]Code: http://127.0.0.1:8074Step 4: Move the real site in
Handy commands Code: docker ps --filter name=legacy-php74 # is it running?
docker logs --tail 50 legacy-php74 # PHP and web server errors
docker restart legacy-php74 # restart it
docker rm -f legacy-php74 # remove it (your files in /srv stay)Got an old app that won't start in the container? Reply below with the lines from Code: docker logs |