in Crash Course

How to install suPHP on cPanel

Update (Feb-27-2011): We’ve released a cPanel plugin that runs along with Apache and cPanel and improves performance tremendously (more than 95%) on a cPanel suPHP server. The plugin is leveraging the Varnish high performance HTTP accelerator. Read about it all here: http://www.unixy.net/varnish

suPHP is a module that enhances overall server security. It forces the system to execute PHP scripts with user privileges as opposed to Web server privileges. suPHP is a good security measure especially when you expect to host multiple unrelated websites or hosting accounts. It keeps rotten apples away from the good ones! Keep in mind that UNIXY is a truly fully managed server company. We are always happy to assist our customers in accomplishing tasks such as installing suPHP on their dedicated server or cluster. If you decide to hire UNIXY to install suPHP on your server, we are currently offering the service for a one-time fee here.

This small guide will go over the installation of suPHP on a cPanel server. cPanel has a peculiar way of setting up suPHP. The good news is that cPanel simplifies the installation! Here’s an overview of the required steps:

  1. Install suPHP Using EasyApache
  2. Configure suPHP
  3. Verify The Configuration

It’s important to pick a maintenance window that is less intrusive on your users or customers. The rebuild of Apache to support suPHP can cause down time. So be sure to send out a friendly email to your customers.

  1. Install suPHP Using EasyApache

There are two ways to launch the EasyApache program. The first one is through SSH and the other via WHM. I prefer SSH so the rest of this guide will be based on that method. So go ahead and remote into the server as user root. Once logged in, run the easyapache script as such

/scripts/easyapache

The first textual screen that pops up will say the following: “Please choose a profile to load.” Simply hit the Tab key twice. The textual box “Start customizing based on profile” will become highlighted. At which point will hit the Enter key on your keyboard. Once you hit Enter, you will be presented with another screen. This time the screen says: “Please choose which apache to build.” Simply hit the Tab key once and then hit Enter again.

There are two more screen to go and we’re done. After hitting the Enter key above, another screen will pop up. This time it says: Please choose which main PHP versions (if any) to build.” Hit the Tab key once and then the Enter key. Follow the same instructions for the screen with title “Please choose which specific PHP version(s) to build.” The next screen, however, is very important. This is where we get to pick the suPHP module that we are building. Once you hit Enter in the previous step, the screen “Short Options List” comes up. Go ahead and hit the Tab key a few times until “Exhaustive Options List” is highlighted then press Enter. Scroll down the list of options until you cursor is on the entry “Mod SuPHP…”.  Hit the Space key once to check the box. Hit the Tab key once then Enter, then select “Save and Build”. Answer Yes to all questions

At this point the build has started. Wait for the build to complete. It’s important that no one uses WHM while the build is in progress. The build takes about 20 minutes to complete depending on server resources. Once the build is finished, proceed to step 2 below.

2. Configure suPHP

This is an important step because it formally enables suPHP. Simply run the following command

/usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1

We’re essentially telling it that we want PHP version 5 running on suPHP and SUEXEC. To verify that command has taken effect run the following command. The output should be indentical:

# /usr/local/cpanel/bin/rebuild_phpconf –current
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: suphp
SUEXEC: enabled

So far so good! Now go ahead and restart Apache by running the following command:

/scripts/restartsrv_httpd

3. Verify The Configuration

At this point all should be working fine. But it’s prudent to keep an eye on the suPHP log file as that’s where errors and warnings show up. The suPHP log file is located here:

/usr/local/apache/logs/suphp_log

Most errors are related to permissions on PHP files. suPHP is very picky about permission and / or file ownership so be sure your PHP files have permission 755 and are owned by the same user account. You can change permission on any file using the following command:

chmod 755 <filename>

You can also change file ownership using the chown command:

chown user.user <filename>

I hope this is useful to anyone setting to install suPHP on a cPanel server.

Write a Comment

Comment

Comment moderation is enabled. Your comment may take some time to appear.

  1. super helpful, having never used easyapache before… i was suprised that it worked great. thanks a bunch for sharing!!

Webmentions

  • cpanel key verify | ???? ????? November 15, 2009

    […] How to install suPHP on cPanel – UNIXy […]

  • hollister t??? November 15, 2009

    hollister t???

    tiffany & company locations

  • bee pollen diet pills November 15, 2009

    bee pollen diet pills…

    Hahahahahahaha, this politics related YouTube video is truly so comic, I loved it. Thanks in support of sharing this….

  • Tweets that mention How to install suPHP on cPanel | UNIXy -- Topsy.com November 15, 2009

    […] This post was mentioned on Twitter by loktar. loktar said: this page was pretty useful in getting it all setup http://blog.unixy.net/2009/05/how-to-install-suphp-on-cpanel/ […]