Install Apache/PHP 7.2.12 on Fedora 29/28, CentOS/RHEL 7.5/6.10
Table of Contents
This guide shows howto install Apache HTTP Server (httpd) with PHP 7.2.12 and following modules on Fedora 29/28/27, CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10 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.2.12 on Fedora 29/28/27, CentOS / Red Hat (RHEL) 7.5/6.10⌗
1.1 Change root user⌗
su -
## OR ##
sudo -i
1.2 Install Remi repository⌗
Fedora⌗
Note: Fedora 29/28 no extra repos needed.
## Remi Dependency on Fedora 27 ##
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
## Fedora 27 ##
rpm -Uvh http://rpms.famillecollet.com/fedora/remi-release-27.rpm
CentOS and Red Hat (RHEL)⌗
## Remi Dependency on CentOS 7 and Red Hat (RHEL) 7 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
## CentOS 7 and Red Hat (RHEL) 7 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
1.3 Install Apache (httpd) Web server and PHP 7.2.12⌗
Fedora 29/28⌗
dnf install httpd php php-common
Fedora 27⌗
dnf --enablerepo=remi --enablerepo=remi-php72 install httpd php php-common
## OR ##
dnf --enablerepo=remi --enablerepo=remi-php72 install httpd php php-common --best --allowerasing
CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10⌗
yum --enablerepo=remi,remi-php72 install httpd php php-common
1.4 Install PHP 7.2.12 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 29/28⌗
dnf install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
Fedora 27⌗
dnf --enablerepo=remi --enablerepo=remi-php72 install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10⌗
yum --enablerepo=remi,remi-php72 install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
1.5 Start Apache HTTP server (httpd) and autostart Apache HTTP server (httpd) on boot⌗
## Fedora 29/28/27 and CentOS/RHEL 7.5 ##
systemctl start httpd.service ## use restart after update
## CentOS / RHEL 6.10 ##
/etc/init.d/httpd start ## use restart after update
## OR ##
service httpd start ## use restart after update
## Fedora 29/28/27 and CentOS/RHEL 7.5 ##
systemctl enable httpd.service
## CentOS / RHEL 6.10 ##
chkconfig --levels 235 httpd on
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.
<?php
phpinfo();
1.7 Check created page with browser⌗
Access following address, with your browser. http://localhost/test.php
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.10⌗
2.1.1 Edit /etc/sysconfig/iptables file:⌗
nano -w /etc/sysconfig/iptables
2.1.2 Add following INPUT rule:⌗
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
2.1.3 Restart Iptables Firewall:⌗
service iptables restart
## OR ##
/etc/init.d/iptables restart
2.2 Fedora 29/28/27 and CentOS/Red Hat (RHEL) 7.5⌗
2.2.1 List Your Active Firewalld Zones⌗
firewall-cmd --get-active-zones
Example output:
public
interfaces: wlp1s0
2.2.2 Add New Rule to Firewalld⌗
You might have active zone like public, FedoraWorkstation, FedoraServer.
firewall-cmd --permanent --zone=public --add-service=http
## OR ##
firewall-cmd --permanent --zone=public --add-port=80/tcp
2.2.3 Restart firewalld.service⌗
systemctl 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 29/28/27, CentOS 7.5/6.10, Red Hat (RHEL) 7.5/6.10