Run php5.6 applications on Cyberpanel

If you need to run a Laravel/WordPress or even a basic website running on php56
Let’s use domain oldapplication.com as the domain you are going to set up the old application for.
A website should be created for oldapplication.com and a database as required in Cyberpanel.

  1. Navigate to https://myserver.com:8090/docker/manageImages

  2. Search for “sajetek/php56-70-71-72-73-ols-ssl-centos7” or “sajetek/php5.6-ols-ssl” or “sajetek/php5.6-apache2.4-ssl” If you prefer Apache backend. (this is not too important as we are only using it for serving)
    Read the overview of both here to know which modules are enabled by default:
    If you are using sajetek/php56-70-71-72-73-ols-ssl-centos7: then as root user execute this mysql query:

ALTER TABLE cyberpanel.dockerManager_containers CHANGE image image VARCHAR(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;

  1. Select Tag: latest and click “Pull”

  2. Once it’s pulled, click “CREATE CONTAINER”

  3. Select Tag: latest and click “Create”

  4. Select your owner, set Memory limit and set ports to whatever you desire. I usually use 8443 for 443, 8000 for 80, 8708 for 7080

  5. DEFAULT_PHP can be set to an appropriate value (see docker overview for each image) but for this tutorial, leave it as 56

  6. DOCUMENT_ROOT for WordPress or basic sites you can leave this as “/” but for Laravel applications, you want to set this to “/public” so that the public folder is your root directory


    If you used sajetek/php5.6-apache2.4-ssl, then set DOCUMENT_ROOT to “/var/www/html” or for Laravel applications, you want to set this to “/var/www/html/public” so that the public folder is your root directory

  7. Click “Add field”. For Destination, set “/usr/local/lsws/Example/html” and Source should be set to your document root which is usually “/home/oldapplication.com/public_html”

  8. Check “Start on reboot” if required and then click “Save”

  9. Navigate to https://myserver.com:8090/websites/oldapplication.com and click on “vHost Conf”

  10. In your rewrite section add the following line “REWRITERULE ^(.*)$ https://dockeroldapplication443/$1 [P]” to make it look similar to the following:

rewrite {
enable 1
autoLoadHtaccess 1
#ENFORCE REDIRECT TO HTTPS
REWRITERULE ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]
REWRITERULE ^(.*)$ https://dockeroldapplication443/$1 [P]
}

  1. Via SSH or SFTP whichever you have (See image for setting from WebAdmin Console), edit /usr/local/lsws/conf/httpd_config.conf and add the following to the bottom of the file (modify as required):

extprocessor dockeroldapplication443 {
type proxy
address https://127.0.0.1:8443
maxConns 100
pcKeepAliveTimeout 60
initTimeout 60
retryTimeout 0
respBuffer 0
}

  1. Restart openlitespeed

If you do NOT need Database Access then you are completed.
IF you DO need Database access, then continue the tutorial.

  1. Navigate to https://myserver.com:8090/dataBases/listDBs and select your domain. Click Manage for the database for your application and set the IP address to “172.17.0.2” and click “Save Changes”
    IP 172.17.0.2 will be the IP of your first docker container. To accurately get the IP use:
    docker inspect {insert_container_id} | jq '.[0].NetworkSettings.Networks.bridge.IPAddress'

  2. Edit the database credentials for your application and set the host to your server’s IP address

  3. Allow “172.17.0.2” access to port 3306 through your server’s firewall. For csf, you can add the following to the allow list “tcp|in|d=3306|s=172.17.0.2”

This allows you to run your application/website on a proxy to my docker image which runs on CentOS 7 and php5.6.
Your website files and databases remain on your host server which can be managed via backups as needed.

If this helped, Please leave a donation

Good tutorial, but sadly a little outdated.
Now that PHP 7.x is outdated, the only most supported PHP version around is 7.4, but new OS updates only allow 8.x
I still use 7.4, as it is the oldest that Almalinux 8.10 allows.
But it is really stable.

Well that’s the point of the tutorial.
This is for those who would like to be running on the latest OS e.g. Almalinux 9 or Ubuntu 22 but may have an application that runs on php5 or an older php 7.0 etc which is not compatible on the new OS.

This allows you to still run php 7.3 and older versions on your new OS through docker. Files and databases are still server through Cyberpanel which allows for the use of backups etc.