suPHP Setup on CentOS 6.x

Reading around online and having set up mod suPHP on CentOS myself it seems there are a lot of issues that pop up. Mainly, some users are missing dependencies, get newer and different errors each time, and so forth. Everyone, it seems, is involved in a never-ending dispenser of errors that must be solved.

So far the easiest way to setup suPHP on CentOS 6 has been the following and this should be a quick one. This was done on CentOS 6.5 64-bit.

  1. Add RPM Forge repository.
    rpm -ivH
    rpm -ivH
  2. Disable RPMForge by default (if you leave things like this enabled, it will break your system).
    # sed -i 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo
  3. Install mod_suphp via yum:
    # yum install mod_suphp -y --enablerepo=rpmforge
  4. !! Important !!: Correct the PHP Handler:
    # sed -i 's/x-httpd-php=php:\/usr\/bin\/php/x-httpd-php=\"php:\/usr\/bin\/php-cgi\"/g' /etc/suphp.conf

    If you do not perform the above (replace "x-httpd-php=php:/usr/bin/php" with "x-httpd-php="php:/usr/bin/php-cgi"") you will get the similar issues to the following errors:

    [error] [client] SecurityException in Application.cpp:511: Unknown Interpreter: php
    [error] [client] Premature end of script headers: index.php
  5. Make sure to set PHP to load via fastCGI and NOT the normal "Apache 2.0 Handler". You can see this via a PHPINFO page.
    # yum install mod_fastcgi --enablerepo=rpmforge -y
  6. Shut off the normal Apache handler for PHP files. This will be in your /etc/httpd/conf.d/php.conf:
    16 #<FilesMatch \.php$>
    17 #    SetHandler application/x-httpd-php
    18 #</FilesMatch>
  7. Example vhost config (/etc/httpd/conf.d/
    <VirtualHost ip-address:80>
            DocumentRoot /path/to/web/document/root
            ErrorLog /var/log/httpd/
            CustomLog /var/log/httpd/ combined
            DirectoryIndex index.php index.html
            suPHP_Engine on
            suPHP_UserGroup user group
            AddHandler x-httpd-php .php
            suPHP_AddHandler x-httpd-php
            php_admin_value open_basedir "/path/to/web/root:/usr/lib/php:/usr/local/lib/php:/var/lib/php/session:/tmp"
            <Directory />
            AllowOverride All
  8. Things to Consider and Edit
    • Vhost Configuration: Set the IP Address
    • Vhost Configuration: Set the server address (web domain)
    • Vhost Configuration: Set the document root
    • Vhost Configuration: Set the document root for the open_basedir
    • Vhost Configuration: Set the user and group. In systems like RHEL / CentOS, these are usually the same.

You should be able to restart Apache now and not have any issues.

If, however, you do have issues please let me know so I can spin up some more machines and give it another whirl.

You may also like...

4 Responses

  1. Nick says:

    Thanks for the step by step, worked a charm :)

  2. justmecrea says:

    Hello, i am very noob about apache and php interpreter installation, i just updated PHP 5.4 To 5.4 and

    i discovered after an error , missing suPHP.conf, and after that,

    i did an RPM installation of mod_suphp-7.0

    after that, error message says to me, GID is too small

    ; Security options

    ;Check wheter script is within DOCUMENT_ROOT

    ;Send minor error messages to browser

    ;Handler for php-scripts

    ;Handler for CGI-scripts

    after that it sa

    SecurityException in Application.cpp:511: Unknown Interpreter: php, referer:

    i am very tired to be stopped in my production, anybody else can help me ?


  3. justmecrea says:

    [Solved] Again :

    I followed this tutorial :

    it seems work better, so, i think the supPHP, problem it solved, i think i have to understand 5.3 to 5.4 impact in my website

  4. terry says:

    The rpmforge repository used in the article appears to be dead. I found a mirror repository via this post:

    Also, before finding this article I upgraded to php 5.6 via the Remi repository in this post:

    That broke suPHP. For some reason, adding the mod_fastcgi made suPHP suddenly start working again. I don't get why... If the author still checks these comments, I'd love some insight as to why mod_fastcgi made suphp suddenly start working again.

Leave a Reply

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