# Upgrade PHP From 5.4 to 7.0 on a CentOS 7 Cloud Server

The default version of [PHP](https://www.ionos.com/digitalguide/websites/website-creation/learn-php-our-all-encompassing-php-tutorial-for-beginners/ "Learn PHP: our all-encompassing PHP tutorial for beginners") available on a new Cloud Server running [CentOS](https://www.ionos.com/digitalguide/server/know-how/what-is-centos-versions-system-requirements/ "What is CentOS? Versions &amp; system requirements") 7 is version 5.4. Learn how to upgrade this to PHP 7.0. You will need to perform the upgrade by hand, since PHP 7 is not available in the standard CentOS 7 yum repository, because it is not considered stable.

---

### Note

This is a significant upgrade, with potential for causing serious conflicts with any web software you may be running.

We strongly recommend that you create a snapshot of your server before you proceed. This will allow you to roll back any changes if you encounter a problem with the upgrade.

---

## Requirements

- A Cloud Server running CentOS 7
- PHP version 5.4

Use the php -v command to verify your current PHP version:

```none
[jdoe@localhost ~]$ php -v
PHP 5.4.16 (cli) (built: Nov  6 2016 00:29:02)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
```

## Upgrade to PHP 7

We will be using the [IUS repository](https://ius.io/ "IUS repository") to upgrade PHP. Although there are several repositories which have made available versions of PHP 7 for CentOS 7, IUS is the only one which carries the official recommendation of the CentOS Project.

```none
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
```

Remove the existing version of PHP:

```none
sudo yum remove php-common mod_php php-cli
```

Update packages:

```none
sudo yum update
```

Install PHP 7:

```none
sudo yum install php70u php70u-pdo php70u-mysqlnd php70u-opcache php70u-xml php70u-gd php70u-devel php70u-mysql
```

Restart Apache:

```none
sudo systemctl restart httpd
```

Use the php -v command to verify that PHP has been upgraded:

```none
[jdoe@localhost erika]# php -v
PHP 7.0.18 (cli) (built: Apr 13 2017 15:18:10) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.18, Copyright (c) 1999-2017, by Zend Technologies
```


This is a markdown version of: [https://www.ionos.com/digitalguide/websites/web-development/upgrade-php-on-a-centos-7-cloud-server/](https://www.ionos.com/digitalguide/websites/web-development/upgrade-php-on-a-centos-7-cloud-server/) for AI/LLM consumption.