Installing & Configuring suPHP

IMPORTANT NOTE: If you’re doing this for WordPress or Drupal or other CMS and you have an SSL backend or an SSL (HTTPS) and normal HTTP domain simultaneously you’ll need to complete this for both vhosts, otherwise you will not be able to upload media, themes or plugins when logged in.

Centos 5.x
rpm -ivh http://pkgs.repoforge.org/mod_suphp/mod_suphp-0.7.1-1.el5.rf.i386.rpm
rpm -ivh http://pkgs.repoforge.org/mod_suphp/mod_suphp-0.7.1-1.el5.rf.x86_64.rpm

Centos 6.x
rpm -ivh http://pkgs.repoforge.org/mod_suphp/mod_suphp-0.7.1-1.el6.rf.i686.rpm
rpm -ivh http://pkgs.repoforge.org/mod_suphp/mod_suphp-0.7.1-1.el6.rf.x86_64.rpm

1. Change the following bolded lines in /etc/suphp.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[global]
logfile=/var/log/httpd/suphp_log
loglevel=info
webserver_user=apache
docroot=/
env_path=/bin:/usr/bin
umask=0077
min_uid=500
min_gid=500

; 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=true

[handlers]
;Handler for php-scripts
x-httpd-php="php:/usr/bin/php-cgi"

;Handler for CGI-scripts
x-suphp-cgi="execute:!self"

2. Make sure /etc/httpd/conf.d/suphp.conf contains only the following two uncommented lines:

LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine off

3. Add the following lines in the < Virtualhost > block of the httpd configuration file(s) for affected Virtualhosts running php applications.

1
2
3
4
5
6
7
8
9
10
11
12
ServerAdmin joe@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog /var/log/httpd/error-example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
suPHP_Engine on
suPHP_UserGroup owner group suPHP_AddHandler x-httpd-php
AddHandler x-httpd-php .php .php3 .php4 .php5
ScriptAlias /cgi-bin/ /var/www/example.com/cgi-bin/
ErrorDocument 404 /404.php

4. Chown the respective docroots to the user who will be the webmaster

chown -Rf user:group /var/www/example.com

5. Restart the web server:

service httpd restart


© 2012 CentosHelp.org