Introduction
Learn how to install and configure PHP for WordPress. WordPress is one of the world's most popular CMS and blogging software packages, and its famous "five minute install" makes it one of the easiest to use.
Most WordPress users will find that it works on their server without having to make any updates or changes to PHP. However, in some cases PHP may need to be updated or configured in order to run WordPress.
Requirements
- A server running Linux
- Root or sudo permissions
Note: For any Cloud Server with Plesk, applications like WordPress should always be installed and managed through the Plesk interface. See our article Use WordPress on a Cloud Server With Plesk for step-by-step instructions.
Checking your Version of PHP
There are two ways to see your PHP version:
Checking the PHP Version From the Command Line
To check your version of PHP from the command line, use one of the following commands, depending on your particular PHP install:
php --version
php5 --version
php-cgi --version
php5-cgi --version

In the above example, the server is running PHP version 5.6.20.
Checking the PHP Version From a Browser
From the command line, go to your web directory and create a phpinfo.php
file:
sudo nano phpinfo.php
Put the following into this file:
<?php phpinfo(); ?>
Save and exit the file, then view the file in a web browser. The PHP version will be displayed at the top of the page.

In the above example, the server is running PHP version 5.4.16.
Updating to the Most Recent PHP Version
Note: The current version of WordPress recommends PHP version 5.6 or greater. This version of PHP requires Apache version 2.4.
Ubuntu 14.04
On newer Ubuntu and Debian systems including Ubuntu 14.04, update PHP with the commands:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
CentOS 6
On older CentOS and Red Hat systems including CentOS 6, first add the new repositories:
sudo wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm
sudo wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm
Next, enable the two REMI repositories. Edit the repository file:
nano /etc/yum.repos.d/remi.repo
- In the first section
[remi]
changeenabled=0
toenabled=1
. - In the second section
[remi-php55]
changeenabled=0
toenabled=1
.
Save and exit the file, then upgrade PHP with the command:
sudo yum upgrade php*
CentOS 7
On newer CentOS and Red Hat systems including CentOS 7, first add the new repositories:
sudo wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
sudo wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-7.rpm
Next, enable the two REMI repositories. Edit the repository file:
nano /etc/yum.repos.d/remi.repo
- In the first section
[remi]
changeenabled=0
toenabled=1
. - In the third section
[remi-php56]
changeenabled=0
toenabled=1
.
Save and exit the file, then upgrade PHP with the command:
sudo yum upgrade php*