How to Install PHP 7.4 on Amazon Linux 2 (Resolve Dependency)
In this post, we will learn how we can install PHP 7.4 on Amazon Linux 2. Amazon Linux 2 is an operating system provided by Amazon Web Services (AWS). It provides a secure, stable, and high-performance execution environment to develop and run enterprise-level applications on AWS Cloud.
- Amazon Linux 2 Server
- you should have sudo or root-level privileges
Update the system
Before proceeding, update the system using the below command. it is always recommended to keep the system up to date. it will make your system more secure and stable.
# yum update
Note:- if you already have PHP installed on the system then remove first otherwise it will generate package conflict issue.
# yum remove php*
For installing the PHP 7.4 we need to install epel and remi repository so, Use the below command and install it.
## epel repo # amazon-linux-extras install epel ## remi repo # rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm ## import GPG key of remi repo # rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
Install dependency and httpd
Now, we need to install ncurses-compat-libs library and httpd server on the system.
# yum install ncurses-compat-libs # yum install httpd
Here, we have disabled amzn2-core repository because in default repository php 5.4 is available
Now, we can install pp using below command.
# yum install php --enablerepo=remi-php74 --disablerepo=amzn2-core
# php -v
[root@linuxfork ~]# php -v PHP 7.4.7 (cli) (built: Jun 9 2020 10:57:17) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies [root@linuxfork ~]#
If you have installed WordPress then for resolving the below error we need to install php-mysqld package
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
# sudo yum install php-mysqlnd
In this post, we have learned how to install PHP 7.4 on Amazon Linux 2. if you are facing any issue please put a message in the comment section.
I am a professional Cloud Engineer and founder of LinuxFork. I am working on Infrastructure Deployment and focusing on the integration of open source technologies with the Cloud. I am an avid Linux lover and open source enthusiast. mostly, I am working with Redhat and Ubuntu Linux in the production environment. apart from this I always believe in knowledge sharing.