Hosting Theory

What is suPHP?

suPHP is a PHP handler for executing PHP scripts with the permissions of their owners. In other words, suPHP helps you avoid permissions issues when running your php scripts.

On a default setup where PHP runs as a DSO (Dynamically Loadable [Apache] Module), when your script writes a file it does so under user ‘nobody’. In order to write a file on a linux box the permissions of the folder have to allow write access for your user. As an example, if you want to write a file — or write to a file — through a PHP script which is running PHP as DSO (apache user ‘nobody’) to folder /home/servint/public_html the permissions of the folder would have to be set to 777 (world-writable permissions). Alternatively, the pre-existing file to which you were writing would have to have 777 permissions.

When running PHP as suPHP all of your PHP scripts are executed as the user whose home directory you are in. Using the example above, if you were to run a PHP script in /home/userA/public_html/write-a-file.php the file would be executed as user ‘userA’ (the owner of the account).

The downside of using suPHP is that it causes a lot of additional CPU usage. For each PHP process/script which is executed, a separate CGI process is started (under your user) which actually executes the script. The amount of additional CPU which is used varies depending on the content of your script.

To Install suPHP on cPanel/WHM, see our article on the topic.

Find out more about ServInt solutions
VPS

Starting at $27

  • The New York Times
  • The Hill
  • Bloomberg
  • The Seattle Times
  • Computer World
  • Ars Technica
  • MSNBC