Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old PHP versions #1408

Open
renatoiub opened this issue Feb 6, 2025 · 3 comments
Open

Old PHP versions #1408

renatoiub opened this issue Feb 6, 2025 · 3 comments

Comments

@renatoiub
Copy link

How to install old versions of php (5.4, 7.4) in the current version of cypberpanel?

@master3395
Copy link
Contributor

If you check here, you can see what PHP version can be installed to what OS version
https://github.com/master3395/cyberpanel/tree/stable

@renatoiub
Copy link
Author

@master3395 I use Ubuntu 22.04 and I only have versions 8 available, I would like to use other older versions without having to change my operating system and without having to downgrade the version, is there any possibility?

@master3395
Copy link
Contributor

Yes, you can install older php versions on Ubuntu 22.04

PS: Not recommended because of security.

Click to expand full code ## Installing PHP 5.6 on Ubuntu 22.04 with CyberPanel

⚠ Warning: PHP 5.6 is deprecated and no longer receives security updates. Running it on Ubuntu 22.04 can introduce security risks. It is recommended to use containers (Docker) or a dedicated virtual machine to isolate PHP 5.6.


✅ Step 1: Install Required Dependencies

Update packages and install dependencies:

sudo apt update && sudo apt upgrade -y
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update

✅ Step 2: Install PHP 5.6 and Required Extensions

sudo apt install -y php5.6 php5.6-cli php5.6-fpm php5.6-mysql php5.6-xml \
php5.6-mbstring php5.6-curl php5.6-zip php5.6-gd php5.6-soap php5.6-bcmath \
php5.6-intl php5.6-readline

Verify installation:

php5.6 -v

Expected output:

PHP 5.6.x (cli) (built: ...)
Zend Engine v2.6.0

✅ Step 3: Configure PHP 5.6 for CyberPanel

1. Check existing PHP versions in CyberPanel

ls /usr/local/lsws/lsphp*

2. Create a directory for PHP 5.6

sudo mkdir -p /usr/local/lsws/lsphp56

3. Symlink PHP 5.6 binaries

sudo ln -s /usr/bin/php5.6 /usr/local/lsws/lsphp56/bin/php
sudo ln -s /usr/sbin/php5.6-fpm /usr/local/lsws/lsphp56/bin/php-fpm

4. Edit CyberPanel's LiteSpeed configuration

sudo nano /usr/local/lsws/conf/httpd_config.conf

Add this block:

extprocessor lsphp56 {
    type                    lsapi
    address                 uds://tmp/lshttpd/lsphp56.sock
    maxConns                10
    env                     PHP_LSAPI_CHILDREN=10
    env                     LSAPI_AVOID_FORK=200M
    initTimeout             60
    retryTimeout            0
    persistConn             1
    pcKeepAliveTimeout      60
    respBuffer              0
    autoStart               1
    path                    /usr/local/lsws/lsphp56/bin/lsphp
    backlog                 100
}

Save and exit (CTRL + X, then Y, then Enter).


✅ Step 4: Restart Services

sudo systemctl restart lsws
sudo systemctl restart php5.6-fpm

✅ Step 5: Add PHP 5.6 to CyberPanel

  1. Log in to CyberPanel.
  2. Navigate to Websites → List Websites.
  3. Select the domain requiring PHP 5.6.
  4. Click Manage.
  5. Scroll to PHP Version, manually enter lsphp56, and save.
  6. Restart the website.

✅ Step 6: Test PHP 5.6

Create a test file:

sudo nano /home/example.com/public_html/info.php

Add this content:

<?php
phpinfo();
?>

Save and exit.

Now, visit:

http://example.com/info.php

You should see the PHP 5.6 information page.


🎯 Alternative: Use Docker for Security

If security is a concern, use a Docker container:

docker run -d --name php56 -p 9000:9000 php:5.6-fpm

Then, configure CyberPanel to use localhost:9000 as the external PHP processor.


🎯 Final Notes

  • If possible, migrate to a newer PHP version.
  • If PHP 5.6 is required, isolate it in a container or VM.
  • If using it directly, disable public access to PHP 5.6 applications.

🚀 Now PHP 5.6 is installed and configured on CyberPanel with Ubuntu 22.04!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants