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.
- Add RPM Forge repository.
32-bit: rpm -ivH http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm 64-bit: rpm -ivH http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
- 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
- Install mod_suphp via yum:
# yum install mod_suphp -y --enablerepo=rpmforge
- !! 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
- 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
- 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>
- Example vhost config (/etc/httpd/conf.d/example.com.conf
<VirtualHost ip-address:80> NameVirtualHost example.com ServerName example.com ServerAlias www.example.com ServerAdmin email@example.com DocumentRoot /path/to/web/document/root ErrorLog /var/log/httpd/example.com-error_log CustomLog /var/log/httpd/example.com-access_log 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 </Directory> </VirtualHost>
- 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.
Thanks for the step by step, worked a charm :)
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, suphp.so
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 ?
[Solved] Again :
I followed this tutorial : http://centoshelp.org/servers/web/installing-configuring-suphp/
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
The rpmforge repository used in the article appears to be dead. I found a mirror repository via this post: https://github.com/repoforge/rpms/issues/375
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.