Traducciones al Español
WordPress is one of the most popular không tính tiền web publishing tools available. Authoring content on WordPress is straightforward, however, you need to perform regular maintenance on your WordPress site to lớn keep it secure & up to date. One of those maintenance tasks is lớn regularly updatePHP, which WordPress uses as a server-side programming language. This guide explains how và when khổng lồ upgrade PHP without adversely affecting your site.
Bạn đang xem: Upgrade php version 7
Why You Should upgrade PHP for Applications lượt thích 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 & makes any site using an outdated version an easier target for intruders. Therefore, it is very important khổng lồ use the minimum supported version of PHP and keep all PHP packages updated.
Some reasons to lớn keep WordPress and PHP updated are listed below:An outdated PHP installation can cause security issues. These flaws might allow the site lớn be compromised.WordPress can have compatibility issues with older versions of PHP, especially after an update. Themes & 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 lớn upgrade PHP if this task is left too long. Plug-ins & themes might not work properly afterward, which could require major rework.
Updating PHP is more complex than updating themes và 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 & upgrade the packages on the darkedeneurope.com regularly.Use strong passwords khổng lồ access the WordPress Dashboard.Take regular backup copies of the site and its database.Regularly upgrade themes or plug-ins và keep all licenses.
Before You BeginNote
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 và Groups guide.
How to Update PHP
PHP usually has lớn be upgraded in one of two situations; when WordPress is first installed, or when it is upgraded khổng lồ 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 lớn version 7.4. These instructions are designed for Ubuntu users but are generally applicable lớn all Linux distributions.Note
Certain plug-ins or themes might not be compatible with the latest version of PHP. In this case, temporarily use an older version.
How lớn Determine if PHP Should Be Updated
The easiest way khổng lồ tell whether the current version of PHP does not meet the minimum requirements is to đánh giá 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 khổng lồ update it. The panel also displays the minimum recommended version of PHP. This is currently version 7.4. Lớn suppress this warning, PHP must be updated khổng lồ this version or a more recent one.
Third-party WordPress management panels can hide maintenance issues related lớn PHP & other components.
How to check Your Current Version of PHP
There are two ways lớn 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 thư mục on the darkedeneurope.com. In the long run, it is much safer to lớn back up the files & database to lớn external storage space. This preserves the archive in the sự kiện the vps hard drive becomes corrupted or access to the hệ thống is permanently lost. However, to lớn quickly tăng cấp WordPress or PHP, a temporary backup copy can be made somewhere else on the darkedeneurope.com.Note
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 lớn 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 website 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 khổng lồ version 7.4.
Xem thêm: download game dn sea
sudo systemctl restart apache2Reload the WordPress Control Panel. The notification about the outdated PHP application should no longer be visible.
How lớn 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 lớn 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 danh sách 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 danh mục 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 lớn 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, phối 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 BackupThe backup procedures are executed in reverse lớn restore the backup copy.Note
Do not địa chỉ 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 lớn restore the backups, inspect the site. If all the content is still available và the site is behaving normally, it might not be necessary khổng lồ restore the archive. If any nội dung appears to be missing, something does not look right, or khổng lồ guarantee the site content has not changed, proceed with the next steps.
Copy the backup copy of the WordPress site from the temporary directory lớn /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 menu all of the MySQL databases, run the command SHOW DATABASES;.
DROP DATABASE wordpress;Re-create the database and grant privileges to lớn the WordPress user. Replace username with the name of the actual WordPress user account.