To Update PHP version to newer or different version follow below steps:
Step 1: Check Existing PHP Version
$ php -v
Step 2: Update Yum
$ sudo yum update
Step 3: Stop the running web server
$ sudo service httpd stop
Step 4: Remove all existing PHP Packages
$ sudo yum remove php*
Step 5: Remove Old Web Server Installs
$ sudo yum remove httpd*
Step 6: Update Yum Package Repository
$ sudo yum clean all
$ sudo yum upgrade -y
Step 7: Install Apache
sudo yum install httpd
Step 8: Confirm that the amazon-linux-extras package is installed
$ which amazon-linux-extras
if command returns /usr/bin/amazon-linux-extras that means it is installed otherwise type below command to install
$ sudo yum install -y amazon-linux-extras
Step 9: Confirm desired version is available on AWS EC2
$ sudo amazon-linux-extras | grep php
it will output
42 php7.4=latest enabled [ =stable ]
_ php8.0 available [ =stable ]
Step 10: Disable Existing Version
$ sudo amazon-linux-extras disable php7.4
Step 11: Enable version you want to install
$ sudo amazon-linux-extras enable php8.0
Step 12: Install PHP Packages
$ sudo yum clean metadata
$ sudo yum install php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}
Step 13: Install mod_ssl
sudo yum install mod_ssl
Step 14: Restart server
$ sudo httpd restart
Step 15: Check PHP version
$ php -v
If you getting requested url not found on server for all pages except home page. Set AllowOverride to All in httpd.conf file at /etc/httpd/conf
<Directory "/var/www/html">
AllowOverride All
</Directory>
- Log in to post comments
Comments
Thank you so much to show…
Thank you so much to show this solution, now I can could update my php version to 8.3.2 with success but at moment I have some problems with Code Build because it's using php 7.0 too... I try some thinks without solution, Had you this problem too?
Regarts