Compile and Install Apache-2.4.x + PHP-5.4.x + Suphp-0.7.1


Compile Apache-2.4.x + PHP-5.4.x + Suphp-0.7.1


Download and compile Apache-2.4.x as described in
http://linuxadmintips4u.blogspot.in/2012/07/configure-apache.html

Download and compile PHP-5.4.x as described in
http://linuxadmintips4u.blogspot.in/2013/05/complile-and-install-php-from-source.html

Once you compiled Apache-2.4.x with PHP-5.4.x, you can follow the steps shown below to compile suphp-0.7.1

Complile SuPHP



[root@vps ~]# cd /usr/local/src/
[root@vps src]# wget http://www.suphp.org/download/suphp-0.7.1.tar.gz
[root@vps src]# tar -xzf suphp-0.7.1.tar.gz

***The package, suphp-0.7.1.tar.gz cannot install with Apache2.4.x. You will get errors while using 'make'. You need to patch it before using it.
***There is no need to patch suphp-0.7.1 if you are compiling with Apache-2.2.x and Apache-2.0.x


[root@vps src]# wget -O fix1.diff https://sites.google.com/site/sudosuin/fix.diff
[root@vps src]# patch -Np1 -d suphp-0.7.1 < fix.diff
patching file configure.ac
patching file src/Makefile.am
patching file src/Makefile.in


[root@vps src]# cd suphp-0.7.1

-------------------------------------------------------------------------------------------------------------------------------------
Locate the location of 'php-cgi' binary file and the binary file location must be specifiled as --with-php=<php-cgi path>
[root@vps ~]# locate php-cgi
/usr/local/php/bin/php-cgi

Locate the location of 'apxs' binary file and the binary file location must be specifiled as --with-apxs=<apxs path>
[root@vps ~]# locate apxs
/usr/local/apache/bin/apxs

Locate the location of 'apr-1-config' binary file and the binary file location must be specifiled as --with-apr=<apr-1-config path>
[root@vps ~]# locate apr-1-config
/usr/local/apr/bin/apr-1-config

---------------------------------------------------------------------------------------------------------------------------------------


[root@vps suphp-0.7.1]# ./configure \
--with-logfile=/var/log/suphp.log \
--with-apxs=/usr/local/apache/bin/apxs \
--with-php=/usr/local/php/bin/php-cgi \
--with-apr=/usr/local/apr/bin/apr-1-config \
--with-setid-mode=paranoid \
--with-gnu-ld \
--disable-checkpath \
--with-apache-user=apache


[root@vps suphp-0.7.1]# make

If there is any error in 'make' try the following two steps also. You can find header files missing error in 'make'. In that case you have to do the header files copy steps as shown below.

Here i have installed apr in /usr/local/apr , apr-uil in /usr/local/apr-util and apache in /usr/local/apache. If you have installed these in any other locations, you have to modify the document root of apr, apr-util and apache in the following two copy commands.

[root@vps ~]# cp /usr/local/apr/include/apr-1/*.h /usr/local/apache/include/
[root@vps ~]# cp /usr/local/apr-util/include/apr-1/*.h /usr/local/apache/include/


[root@vps suphp-0.7.1]# make install

Once you have successfully compiled suphp, you have to do the following configurations.

----------------------------------------------------------------------------------------------
Create a file named /usr/local/apache/conf/suphp.conf with the following contents.

[root@vps ~]# cat /usr/local/apache/conf/suphp.conf
LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php .php
suPHP_AddHandler application/x-httpd-php
suPHP_UserGroup apache apache

----------------------------------------------------------------------------------------------


Create a file named /etc/suphp.conf with the following contents.

[root@vps ~]# cat /etc/suphp.conf


[global]
;Path to logfile
logfile=/var/log/suphp.log

;Loglevel
loglevel=info

;User Apache is running as
webserver_user=apache

;Path all scripts have to be in
;docroot=/var/www:${HOME}/public_html:/home/httpd/html/

;Path to chroot() to before executing script
;chroot=/mychroot

; Security options
allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false

;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true

;Send minor error messages to browser
errors_to_browser=false

;PATH environment variable
env_path=/bin:/usr/bin:/usr/local/php/bin

;Umask to set, specify in octal notation
umask=0022

; Minimum UID
min_uid=0

; Minimum GID
min_gid=0

[handlers]
application/x-httpd-php="php:/usr/local/php/bin/php-cgi"
x-suphp-cgi="execute:!self"
---------------------------------------------------------------------------------------------------

Open Apache configuration file (httpd.conf) and remove the following entry

LoadModule php5_module        modules/libphp5.so

----------------------------------------------------------------------------------------------------
Add the following entry in httpd.conf

Include conf/suphp.conf

----------------------------------------------------------------------------------------------------

Change the following entriens as follows in httpd.conf

User apache
Group apache

------------------------------------------------------------------------------------------------------

Once you have done the following settings, restart apache service and check suphp module is loaded or not.

[root@vps ~]# httpd -M | grep suphp
 suphp_module (shared)

Create a phpinfo page in /usr/local/apache/htdocs and given permission 644 and owner, group as apache and apache. Check if the php page is loading or not. If it is not loading, check the error in /usr/local/apache/logs/error_log.


This entry was posted in by Arun Ghosh. Bookmark the permalink.

3 thoughts on “Compile and Install Apache-2.4.x + PHP-5.4.x + Suphp-0.7.1”

  1. Thanks for sharing this, specially the patching and the missing .h files while compiling. I upgraded our development server to the latest apache and php and everything broke... and not here I'm putting the pieces back together. You have saved me a few hours of further research.

    Regards, MV.