Install Apache/PHP 7.0.9 on Fedora 24/23, CentOS/RHEL 7.2/6.8/5.11

This guide shows howto install Apache HTTP Server (httpd) with PHP 7.0.9 and following modules on Fedora 24/23/22/21/20, CentOS 7.2/6.8/5.11 and Red Hat (RHEL) 7.2/6.8/5.11 systems.

  • OPcache (php-opcache) – The Zend OPcache provides faster PHP execution through opcode caching and optimization.
  • APCu (php-pecl-apcu) – APCu userland caching
  • CLI (php-cli) – Command-line interface for PHP
  • PEAR (php-pear) – PHP Extension and Application Repository framework
  • PDO (php-pdo) – A database access abstraction module for PHP applications
  • MySQL (php-mysqlnd) – A module for PHP applications that use MySQL databases
  • PostgreSQL (php-pgsql) – A PostgreSQL database module for PHP
  • MongoDB (php-pecl-mongodb) – PHP MongoDB database driver
  • Redis (php-pecl-redis) – Extension for communicating with the Redis key-value store
  • Memcache (php-pecl-memcache) – Extension to work with the Memcached caching daemon
  • Memcached (php-pecl-memcached) – Extension to work with the Memcached caching daemon
  • GD (php-gd) – A module for PHP applications for using the gd graphics library
  • XML (php-xml) – A module for PHP applications which use XML
  • MBString (php-mbstring) – A module for PHP applications which need multi-byte string handling
  • MCrypt (php-mcrypt) – Standard PHP module provides mcrypt library support

1. Install Apache HTTP Server (httpd) and PHP 7.0.9 on Fedora 24/23/22/21/20, CentOS / Red Hat (RHEL) 7.2/6.8/5.11

1.1 Change root user

1.2 Install Remi repository


CentOS and Red Hat (RHEL)

1.3 Install Apache (httpd) Web server and PHP 7.0.9

Fedora 24/23/22

Fedora 21

Fedora 20

CentOS 7.2/6.8/5.11 and Red Hat (RHEL) 7.2/6.8/5.11

1.4 Install PHP 7.0.9 modules

Select what you need: OPcache, APCu, CLI, PEAR, PDO, MySQL, PostgreSQL, MongoDB, Memcache, Memcached, GD, MBString, MCrypt, XML

More info about PHP APC from PHP APC Configuration and Usage Tips and Tricks.

Fedora 24/23/22

Fedora 21

Fedora 20

CentOS 7.2/6.8/5.11 and Red Hat (RHEL) 7.2/6.8/5.11

1.5 Start Apache HTTP server (httpd) and autostart Apache HTTP server (httpd) on boot

1.6 Create test PHP page to check that Apache, PHP and PHP modules are working

Add following content to /var/www/html/test.php file.

1.7 Check created page with browser

Access following address, with your browser. http://localhost/test.php
CentOS 7 running Apache and PHP 5.6.0

2. Enable Remote Connection to Apache HTTP Server (httpd) –> Open Web server Port (80) on Iptables Firewall (as root user again)

2.1 CentOS/Red Hat (RHEL) 6.8/5.11

2.1.1 Edit /etc/sysconfig/iptables file:

2.1.2 Add following INPUT rule:

2.1.3 Restart Iptables Firewall:

2.2 Fedora 24/23/22/21/20 and CentOS/Red Hat (RHEL) 7.2

2.2.1 List Your Active Firewalld Zones

Example output:

2.2.2 Add New Rule to Firewalld

You might have active zone like public, FedoraWorkstation, FedoraServer.

2.2.3 Restart firewalld.service

3. Test remote connection

Access following address, with your browser. http://your.domain/test.php

More reading:

Enable Apache Userdir with SELinux on Fedora 23/22/21/20/19, CentOS 7.2/6.7/5.11, Red Hat (RHEL) 7.2/6.7/5.11 >>

Share this post


  1. I can’t install remi I get warning: /var/tmp/rpm-tmp.YFAEEn: Header V3 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
    error: Failed dependencies:

  2. Hi Bud,

    I have already done all this prior to fining your blog but I just cannot get php to run on my Apache it just list the text of the php file as well as if I go to the main page it just lists my virtual pages!!!!!

    • Hi John,

      Did you tested simple /var/www/html/test.php -> http://localhost/test.php without any other configurations?

      Could you post little bit more info about your installed packages:

      And following configs:

  3. Now that we have Apache installed and working properly, we need to make sure that it’s set to start automatically when the Cloud Server is rebooted.

    • Hi Jaime,

      Check step 1.5

  4. Again. Thank you very much. Worked out perfectly on Fedora 21.
    Best wishes!

  5. Thanks for the tricks, but OPCache is not installed on CentOS 7.3 with these instructions. Do you have more advice here?


  6. Thanks again for the forum.Much thanks again. Fantastic.

  7. Hi JR,

    I installed httpd using dnf. I don’t need php. But placing a simple ‘index.html’ file into “var/www/html” and trying to access it at localhost:80/index.html

    I have this message: The requested URL /index.html was not found on this server.

    Any ideas?

    Thank you.


Submit a Comment

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