How to update PHP to latest version on AWS EC2

Warning: Before doing anything, make backups!

 

Remove old versions of PHP and Apache

The old Apache and PHP versions in the server can conflict with the new install. So it is recommended to stop the web server and remove them using the commands:

sudo service httpd stop
sudo service mysqld stop
sudo yum remove httpd* php* mysqld*

Update the packages

New versions and patches for software get released often. That’s why it is always advisable to update the packages in the server.

Updating packages from the repository ensures that you get the latest secure versions and dependencies.

sudo yum clean all
sudo yum update -y

Install new version of PHP, MySQL, and Apache

PHP/MySQL 5.6 works only with Apache 2.4, and they are available as a single package. Install then using:

sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd

Lastly start it!

sudo service httpd start 
sudo service mysqld start

 

3 Responses

  1. Could you please tell me what tool to use to type those above cmd?
    How to connect to amazon hosting server and use what credentials to login?
    My story is I just bought a theme for my website but after installing, i could not activate that theme using purchase code. The theme admin said that i need to update my hosting to latest php version then try activate again. But I dont have any ideas to do this.

    THanks,
    Mong

  2. Instead of manually setting up AWS server and installing PHP on it, why not use Cloudways like PHP hosting platform, where you can instantly launch AWS server with PHP already installed on it? You can save a lot of time and efforts this way.