Search code examples
linuxamazon-ec2php-7rhelapache2.4

Upgrade to php 7 and apache 2.4 from php 5.3 and apache 2.2 in Amazon EC2


I have a legacy system in which Apache 2.2.34 (linux) is installed along with php 5.3.29 (CLI).

I just want to upgrade my apache to 2.4.x so that I will be able to use php 7.

I have tried searching for the same but majority of sites provide solution for CentOS or Ubuntu. I'm new to Linux so I'm a bit confused when applying the same on Amazon EC2 instance.

That would be really helpful if someone can provide me a step by step process to do the upgrade process. I just need to upgrade the server and I can do the configuration accordingly.


Solution

  • After some more googling, I have found the steps I have taken to upgrade. Hope that helps anyone looking for the same:

    Login to your Linux instance and perform the regular system updates first

    $ sudo yum update
    

    Stop the running web server

    $ sudo service httpd stop
    

    Create backup of the existing httpd by using command:

    $ sudo cp -a /etc/httpd /etc/httpd.bak
    

    Remove any existing PHP packages

    $ sudo yum remove php*
    

    Remove old web server installs

    $ sudo yum remove httpd*
    

    Update yum package repository

    $ sudo yum clean all
    $ sudo yum upgrade -y
    

    Install Apache 2.4

    $ sudo yum install httpd24
    

    Install PHP 7 packages

    $ sudo yum install php70 php70-mysqlnd php70-imap php70-pecl-memcache php70-pecl-apcu php70-gd
    

    Install a new version of mod_ssl

    $ sudo yum install mod24_ssl
    

    I also needed to reconfigure /etc/httpd/conf/httpd.conf and /etc/httpd/conf.d/ssl.conf in order to enable SSL and pretty permalinks.

    Finally all I needed to do is start my web server

    $ service httpd start
    

    That's it.