Previous= $store.search.results.main.result.stats.totalNbPages” type=button
Traducciones al Español
WordPress is one of the most popular free web publishing tools available. Authoring content on WordPress is straightforward, however, you need to perform regular maintenance on your WordPress site to keep it secure and up to date. One of those maintenance tasks is to regularly updatePHP, which WordPress uses as a server-side programming language. This guide explains how and when to upgrade PHP without adversely affecting your site.
Đang xem: Upgrade php version 7
Why You Should Upgrade PHP for Applications Like WordPress
At regular intervals, a new version of the open-source PHP application is released. Older versions of the platform then, become obsolete. This means they are no longer updated and do not receive any further security patches. This allows vulnerabilities to accumulate and makes any site using an outdated version an easier target for intruders. Therefore, it is very important to use the minimum supported version of PHP and keep all PHP packages updated.
Some reasons to keep WordPress and PHP updated are listed below:
An outdated PHP installation can cause security issues. These flaws might allow the site to be compromised.WordPress can have compatibility issues with older versions of PHP, especially after an update. Themes and plug-ins might not work with older versions.After PHP is updated, the site might run faster. Newer versions of PHP have performance improvements, and memory usage has also been improved.It often becomes more difficult to upgrade PHP if this task is left too long. Plug-ins and themes might not work properly afterward, which could require major rework.
Updating PHP is more complex than updating themes and plug-ins. PHP cannot be directly updated from the WordPress Dashboard. In addition, you should back up the site before upgrading PHP and, if necessary, restore it afterward.
Additional best practices for WordPress upgrades are listed below:
Generate a routine or schedule for upgrades, including PHP upgrades.Update and upgrade the packages on the darkedeneurope.com regularly.Use strong passwords to access the WordPress Dashboard.Take regular backup copies of the site and its database.Regularly upgrade themes or plug-ins and keep all licenses.
Before You Begin
The steps in this guide are written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you are not familiar with the sudo command, see theLinux Users and Groups guide.
How to Update PHP
PHP usually has to be upgraded in one of two situations; when WordPress is first installed, or when it is upgraded to a newer version. Currently, the minimum recommended version of PHP is 7.4, while the latest version of PHP is 8.0. This guide describes how to update PHP to version 7.4. These instructions are designed for Ubuntu users but are generally applicable to all Linux distributions.
Certain plug-ins or themes might not be compatible with the latest version of PHP. In this case, temporarily use an older version.
How to Determine if PHP Should Be Updated
The easiest way to tell whether the current version of PHP does not meet the minimum requirements is to review the WordPress Dashboard. Your Dashboard can be found at yourdomain.name/wp-admin/. If PHP is out of date, a panel on the left-hand side of the Dashboard displays a “PHP Update Recommended” warning. It cautions that “Your site is running an insecure version of PHP” and encourages you to update it. The panel also displays the minimum recommended version of PHP. This is currently version 7.4. To suppress this warning, PHP must be updated to this version or a more recent one.
Third-party WordPress management panels can hide maintenance issues related to PHP and other components.
How to Check Your Current Version of PHP
There are two ways to find out what version of PHP is currently installed.
Consult the WordPress Dashboard. If PHP is out of date, it displays the current version.
Verify the PHP version of PHP from the command line using the following command.
Back up the WordPress site and associated files.Back up the WordPress database.
The WordPress site can be backed up externally using FTP or SCP. It can also be backed up in a different folder on the darkedeneurope.com. In the long run, it is much safer to back up the files and database to external storage space. This preserves the archive in the event the server hard drive becomes corrupted or access to the server is permanently lost. However, to quickly upgrade WordPress or PHP, a temporary backup copy can be made somewhere else on the darkedeneurope.com.
For a nominal fee, darkedeneurope.com can take a snapshot of your site through itsBackup Service. A variety of third-party tools are also available.cPanel can be used to back up a site, but it has a licensing fee. A variety of third-party WordPress plug-ins are also available for this purpose.
If NGINX is used as the web server, the php7.4-fpm package must also be installed.
The php-pear module is also recommended with PHP 7.4.
sudo apt install php-pearVerify PHP has been upgraded to version 7.4.
sudo systemctl restart apache2Reload the WordPress Control Panel. The notification about the outdated PHP application should no longer be visible.
How to Install a Specific Version of PHP
There could be occasions when a different version of PHP is required, for example, when compatibility with a theme must be maintained. To install a specific version of PHP, follow the instructions below.
Depending on the system, the necessary PHP packages might already be available. To determine whether this is the case, follow the steps in the following section.
To verify whether the package for PHP version x.y is already available, run the command sudo apt list phpx.y. If the command displays details about the package, then it can be immediately installed. Packages are available for all currently supported versions.
sudo apt list php7.3Listing… Donephp7.3/focal 7.3.29-1+ubuntu20.04.1+deb.sury.org+1 allInstall this version of PHP.
sudo apt install php7.3If the package is not available, it might be available via the ondrej Personal Package Archive (PPA), developed by Ondřej Surý. This archive provides access to the most recent versions of PHP. The same naming convention as above is used.
Add the ondrej/php repository using apt.
sudo add-apt-repository ppa:ondrej/phpCo-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP () for Supported Ubuntu Releases () are provided.Add the corresponding apache2 PPA.
sudo add-apt-repository ppa:ondrej/apache2Upgrade the packages.
sudo apt-get updateInstall the various PHP packages using the instructions in the previous section.
sudo apt install php5.6If more than one version is installed, set the default version of PHP using the update-alternatives command. The following command sets the default PHP version to 7.0.
sudo update-alternatives –set php /usr/bin/php7.0update-alternatives: using /usr/bin/php7.0 to provide /usr/bin/php (php) in manual mode
How to Restore a Backup
The backup procedures are executed in reverse to restore the backup copy.
Do not add any content or make any changes to the site before restoring the original content. Any further changes are overwritten when the WordPress database is restored.
Before proceeding to restore the backups, inspect the site. If all the content is still available and the site is behaving normally, it might not be necessary to restore the archive. If any content appears to be missing, something does not look right, or to guarantee the site content has not changed, proceed with the next steps.
Copy the backup copy of the WordPress site from the temporary directory to /var/www/html/yourdomainname.com/public_html.
cd ~/wpbackup sudo cp public_html/ -r /var/www/html/yourdomainname.comEnter the MySQL database.
sudo mysql -u rootThe database must be empty before it can be restored, so it must be dropped and then re-created. In most cases, the WordPress database is named wordpress, but it might have been given another name at installation time. To list all of the MySQL databases, run the command SHOW DATABASES;.
DROP DATABASE wordpress;Re-create the database and grant privileges to the WordPress user. Replace username with the name of the actual WordPress user account.