Update PHP in Plesk

PHP, a cornerstone of modern web development, is a scripting language pivotal in creating dynamic and interactive websites. Its widespread adoption, powering a significant portion of the internet, speaks to its robustness and flexibility. However, the digital landscape is constantly evolving, with security threats and performance demands at the forefront. This evolution necessitates the regular updating of PHP to safeguard websites from vulnerabilities and ensure they run efficiently.

Plesk is a comprehensive control panel solution that simplifies the management of web hosting services. Plesk stands out in its ability to streamline the process of updating PHP versions. It provides a user-friendly interface, allowing even those with minimal technical knowledge to keep their PHP installations current. This not only bolsters security but also enhances website performance, ensuring compatibility with the latest web technologies.

Whether you're a seasoned developer or a website owner with basic tech skills, understanding how to update PHP in Plesk is crucial. It’s not just about keeping your site secure and fast; it’s about staying ahead in a rapidly advancing digital world. Let's dive into the process of updating your PHP version in Plesk, ensuring your website remains a robust, secure, and high-performing asset.

Prerequisites

Before updating PHP in Plesk, there are two critical prerequisites you must ensure:

1. Access to Plesk Control Panel

To update PHP, access to the Plesk control panel is non-negotiable. It's the dashboard where all the magic happens. If you're not the server administrator, you may need to get in touch with your hosting provider or the person managing your server to obtain these credentials. Remember, without access to Plesk, updating PHP is not feasible.

2. Backing Up Your Website and Database

The saying "better safe than sorry" holds particularly true here. Before making any changes to your PHP version, it's essential to back up your website and database. This precaution ensures that, in the rare event something goes awry, you can restore your site to its previous state.

  • Website Backup: Utilize Plesk's backup tools to create a complete copy of your site files. This backup should include all files, folders, scripts, and media. Store this backup in a safe location, preferably offsite or in cloud storage.

  • Database Backup: If your website relies on a database (like WordPress or Joomla sites), backing up the database is crucial. Plesk offers tools to export your database in formats like .sql, which can be stored separately from your site files.

These backups are your safety net. Once you've secured them, you're ready to proceed with updating PHP, confident that your data is safeguarded against any unexpected scenarios.

Can't we just roll back to previous PHP version?

While it's true that you can often roll back to a previous PHP version if issues arise after an update, it's still considered best practice to back up your website and database before making any significant changes. Here's why:

  • Unexpected Complications: Even though PHP version rollbacks are generally straightforward, there can be unexpected complications. For instance, some scripts or plugins might not function correctly after reverting, especially if they were updated or modified to accommodate the new PHP version.

  • Data Integrity: During the process of updating PHP, there's a slight chance of affecting database interactions, especially if the update involves changes in PHP's interaction with the database system. A backup ensures that you have a recent snapshot of your data to restore from.

  • Preparation for Other Issues: While the focus here is on updating PHP, other unrelated issues could arise simultaneously, such as hosting problems, accidental file deletions, or other unforeseen errors. A backup ensures you're prepared for a wider range of potential issues.

  • Peace of Mind: Knowing you have a recent backup provides peace of mind. It ensures that, regardless of what happens during the PHP update process, your website can be restored to its pre-update state.

  • Best Practices: Regular backups are a cornerstone of good website management. Making a backup before any major change is a habit that can save significant time and stress in the long run.

Understanding PHP Versions

When managing a website, it's crucial to understand the landscape of PHP versions. PHP, being an evolving language, has multiple versions available, each with its unique features, improvements, and support lifecycles.

Different PHP Versions Available

  • Legacy Versions (PHP 5.x and older): These are outdated and no longer supported by the PHP community. They lack the latest security features and optimizations.
  • Supported Versions (PHP 7.x and PHP 8.x): PHP 7 introduced significant performance improvements and modern coding features. PHP 8, the latest series, further enhances performance and introduces new features like Just-In-Time compilation. Each major version (7.x, 8.x) has minor updates (e.g., 7.1, 7.2, 8.0, 8.1) that often include security patches and performance improvements.

Compatibility Concerns

  • Application Support: Not all applications are immediately compatible with newer PHP versions. For instance, a WordPress site running on an older theme or plugins might experience issues with the latest PHP version.
  • Deprecated Features: New PHP versions sometimes deprecate older functions and features. If your website relies on code that uses these deprecated features, updating PHP could break functionality.
  • Performance Implications: While newer versions generally offer better performance, they might also require more server resources or specific server configurations.

How to Choose the Right Version

  • Check Application Requirements: Before updating, review the requirements of your CMS (like WordPress, Joomla) or any specific applications you are running.
  • Review Change Logs: Change logs for PHP versions can provide insights into what has changed, helping you assess compatibility.
  • Consult with Developers: If your site is custom-built, it's wise to consult with the developers or a technical team to ensure compatibility.

Navigating to PHP Settings in Plesk

Adjusting the PHP settings of your website in Plesk is a straightforward process, but knowing where to look is key. Here’s how you can locate and understand the PHP settings within the Plesk dashboard.

Step 1

Start by logging into your Plesk control panel using your username and password.

Once logged in, navigate to the ‘Websites & Domains’ tab. Here, you'll see a list of your hosted domains.

Select the domain you wish to manage. This action will open a range of management options for that specific domain.

Scroll down to find the ‘PHP Settings’ option. It’s typically under the main dashboard setting. Clicking on ‘PHP Settings’ will open the configuration area for PHP.

php settings in plesk

Step 2

Click the PHP icon. Now, you will see a lot of PHP settings.

select php version

Select the PHP version from the dropdown list that you need.

What if the version that you need is not there?

Installing new PHP version in Plesk

In case the desired PHP version is not availabel in the dropdown list, you can install new PHP versions from Plesk. For this you will need to have root access to Plesk.

Step 1

Log into Plesk with your root user and go to "Tools & settings" -> "Plesk" -> "Updates". This will open a new window:

add new component in plesk

Step 2

Click "Add/Remove Components. Expand the "Web Hosting" section, then expand the "PHP interpreter versions". Here you will see the already installed and available PHP versions.

Step 3

To install a new version, just click the arrow and select "install", then click "Continue".

install new php version in plesk

Plesk will install the selected version and you should receive a success message. The new installed version should be available in the PHP settings now.

Verifying the PHP Version Update in Plesk

Once you've updated the PHP version for your website in Plesk, it's crucial to verify that the change was successful. This ensures that your site is running on the new version and helps identify any immediate issues that need addressing.

Checking the PHP Version

Using Plesk: The simplest way to check is by returning to the PHP Settings of your domain in Plesk. The PHP version currently in use is displayed prominently at the top of this page.

Creating a PHP Info File: For a more detailed verification, you can create a PHP info file.

Create a new file named info.php (or similar) in your website’s root directory.

Add the following code to the file:

<?php phpinfo(); ?>

Access this file through your browser (e.g., http://yourdomain.com/info.php). This page will display the current PHP version and configuration.

Troubleshooting Common Issues

Post-update, you might encounter some issues. Here’s how to troubleshoot common ones:

  • Website Errors or Downtime: If your website doesn’t load or shows errors, the first step is to check for compatibility issues with the new PHP version. Review error logs in Plesk or through the info.php file for specific error messages.
  • Performance Issues: If the website is slower after the update, check the PHP memory limit and execution time settings. Increasing these limits can sometimes resolve performance issues.
  • Functionality Loss: If certain website features stop working, it could be due to deprecated functions or extensions in the new PHP version. Consult the application’s documentation or support for compatibility with the updated PHP version.
  • Rolling Back: If the issues are significant and unsolvable in the short term, consider rolling back to the previous PHP version. This can be done by simply selecting the old version in the Plesk PHP settings.

Conclusion

Regularly updating PHP is more than a technical necessity; it's a commitment to your website's security and efficiency. Each update brings not only performance enhancements but also crucial security patches that protect your site from emerging vulnerabilities. In the ever-evolving digital landscape, staying updated is staying protected.

Plesk, however, offers much more than just PHP management. It's a treasure trove of tools designed to optimize your website’s performance and bolster its security. Explore features like the security advisor, backup manager, and performance monitoring tools. Each of these can play a pivotal role in keeping your site robust and running smoothly.

Remember, the health of your website is a continuous journey. Regular check-ins for PHP updates and a keen eye on Plesk’s array of features will equip you to navigate this journey with confidence.