If you followed AWS's official tutorial: Installing LAMP on Amazon Linux2 to install Wordpress on AWS EC2, you should have PHP7.2 installed on Amazon Linux2. But PHP 7.2 is now out of date. You must update your PHP version to at least 7.4. In this article, we share the update process in detail!
When you go to the Wordpress admin page and the following warning message pops up, it means that you need a PHP update.
The reasons for updating, not simply because Wordpress guides you, are as follows.
- Your website will be faster. (The performance of 7.4 and later versions is better.)
- Your website will be more secure. (The latest version has more security.)
If you have 15 minutes, go ahead!
Before the update
Before update the php, make sure you are ready to do it.
- Backup your wordpress site
- PHP compatibility: PHP Compatibility Checker plugin helps compatibilities checks for your themes and plugins
- Fix PHP compatibility issues: If PHP compatibility checker found issues, contact developer of the thems and plugins to investigate it. If not, find another themes and plugins which are capable of similar functions.
Let's start the update : step by step guide
1. Login to your EC2 instance via SSH tool or AWS connect to instance option
2. Update Yum
$ sudo yum update
3. Check the current version of PHP
$ php -v
4. Check amazon-linux-extras package is installed.
$ which amazon-linux-extras
If the package is installed, you'll see /usr/bin/amazon-linux-extras. Otherwise, install it.
$ sudo yum -y install amazon-linux-extras
5. Confirm desires versions (>7.4) are available in Amazon Linux2
$ sudo amazon-linux-extras | grep php
6. Disable existing PHP (<7.4) and lamp-mariadb10.2-php7.2
$ sudo amazon-linux-extras disable php7.2
$ sudo amazon-linux-extras disable lamp-mariadb10.2-php7.2
7. Enable PHP 8.0
I would like to install PHP8.0 but you can choose your desired version of PHP which is available.
$ sudo amazon-linux-extras enable php8.0
8. Check available PHP version
Just make sure only desired PHP version is enabled.
(Optional) If you update PHP from 7.2 to 8.0, remove php-json to avoid dependency confliction. (php-json is included in PHP8.0 or PHP8.1)
$sudo yum remove php-json
9. Install new PHP version
$ sudo yum clean metadata
$ sudo yum install php php-{cli,pdo,pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,mysqlnd}
10. Check php version once update is finished.
11. Restart the web server to be sure you are using latest PHP
$ sudo systemctl restart httpd
If you've made it this far, congratulations! If you have any problems, leave a comment and I'll check it out.
Reference:
https://wordpress.org/support/update-php/#before-you-update-your-php-version
댓글