Managing PHP versions in XAMPP or operating systems such as Windows, Linux (Debian, Ubuntu) involves several steps. Here's a guide on how to upgrade, update, or downgrade PHP versions in these environments:
1. Upgrade, Update, or Downgrade PHP in XAMPP (Windows/Linux)
1.1. Backup the Old PHP:
Before making any changes, make sure you back up the current PHP folder in the XAMPP directory (C:\xampp\php or /opt/lampp/php on Linux).
1.2. Download the New PHP Version:
Visit the official PHP website and download the desired PHP version (make sure it's the version supported by your XAMPP).
1.3. Extract and Replace the PHP Folder:
Extract the downloaded PHP file and replace the contents of the php folder in the XAMPP directory with the new version.
1.4. Configure PHP:
Copy the php.ini file from the old PHP folder to the new PHP folder.
Adjust the configuration if necessary (e.g., enable specific extensions).
1.5. Test the New PHP Version:
Restart Apache from the XAMPP Control Panel.
Create a phpinfo.php file in the htdocs folder to check the active PHP version:
opening bracket ?php phpinfo(); ?closing bracket
Access this file through a browser (localhost/phpinfo.php).
2. Upgrade, Update, or Downgrade PHP on Linux (Debian/Ubuntu)
2.1. Update the Repository and Install PHP:
First, make sure the repository is up to date:
sudo apt-get update
2.2. Install the Desired PHP Version:
For Ubuntu/Debian, you can add a PPA to install multiple PHP versions:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
After that, install the desired PHP version:
sudo apt-get install php7.4
2.3. Configure Apache:
After installing the PHP version, enable the PHP module in Apache:
sudo a2enmod php8.3
sudo systemctl restart apache2
2.4. Set the Default PHP Version:
If you have multiple PHP versions, you can configure the default PHP version using update-alternatives:
sudo update-alternatives --config php
2.5. Check PHP Version:
Check the PHP version you're using with:
php -v
Additional Notes:
When downgrading, ensure all PHP modules or extensions you're using are compatible with the lower PHP version.
Check the compatibility of running applications before upgrading/downgrading.
By following the steps above, you can manage PHP versions on XAMPP and Linux operating systems (Debian/Ubuntu).
Good luck trying it out!
Copyright Disclaimer:
Under section 107 of the Copyright Act of 1976.
Every video, audio, text, footage, image, etc. in this content is permitted under the terms of Fair Use.
Every content in this channel is for purposes such as education, news reporting, interpretation, etc.
Copyright © 2024 Dunia MR — All Rights Reserved