Upgrading WordPress to PHP7 on Amazon Linux

Major of instructions were taken from StackOverflow. Though I didn’t follow all steps plus I also had to deal with SSL module. Anyway the migration was fast and flawless. Just don’t forget to backup you website 🙂

Here are my instructions if you followed AWS tutorial to setup WordPress on Apache with SSL. Note that following these instructions is relatively safe and doesn’t corrupt any WordPress files (if you on Amazon Linux).

  1. Stop Apache and remove httpd 2.2 and PHP 5:
     sudo service httpd stop
     sudo yum remove httpd* php*
  2. Install Apache 2.4 and mod_ssl
    sudo yum install http24
    sudo yum install mod24_ssl
    
  3. Install PHP 7 and required modules
    sudo yum install php70
    sudo yum install php70-mysqlnd
    sudo yum install php70-gd
    
  4. Update Apache configuration to react on index.php files:
    sudo nano /etc/httpd/conf/httpd.conf

    Find dir_module section and update it to:

    <IfModule dir_module>
      DirectoryIndex index.html index.php
    </IfModule>
    

    Find <Directory "/var/www/html"> and update it to:

    <Directory "/var/www/html">
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all granted
    </Directory>
    
  5. Now it’s time to copy back your SSL configuration:
    sudo mv /etc/httpd/conf.d/ssl.conf.rpmsave /etc/httpd/conf.d/ssl.conf
    
  6. Final steps: adding httpd to boot sequence and launching it:
    sudo chkconfig httpd on
    sudo service httpd start
    

Voila! Your WordPress should be back online running on PHP 7! Many thanks to WordPress, PHP, Apache and Amazon people who surely worked hard to make such transitions so simple and burden-free.

Leave a Reply

Your email address will not be published. Required fields are marked *