Skip navigation
All People > Patrick-Dussault > Patrick Dussault's Blog > 2018 > October
2018

How to compile and run php module with Apache 2.4.16 compiled on RedHat 7.

 

We assume Apache is compiled and installed in /opt/apache2416

 

As root :

 

# cd /root/download
# wget http://at2.php.net/distributions/php-7.2.10.tar.bz2.asc
# wget http://at2.php.net/distributions/php-7.2.10.tar.bz2
# bunzip2 php-7.2.10.tar.bz2
# tar -xvf php-7.2.10.tar
# cd php-7.2.10
# ./configure --with-apxs2=/opt/apache2416/bin/apxs --prefix=/opt/php
# make
# make install

 

php module for apache will be installed here :

 

/opt/apache2416/modules/libphp7.so

 

and added to httpd.conf as

LoadModule php7_module modules/libphp7.so

 

# nano -w /opt/apache2416/conf/httpd.conf

 

and add in section

 

<IfModule mime_module>

 

the following line :

 

AddType application/x-httpd-php .php

 

Now to start apache to execute php 7 as module, modify the environment variable as :

 

# export PATH=/opt/php/bin:${PATH}

 

Then start Apache and all .php file should be interpreted before the
result is sent to the browser !

 

# /opt/apache2416/bin/apachectl start