Minimalist fcgid with custom php.ini on cPanel

I recently changed to using fastcgi on my personal cPanel server (11.28, CentOS) and thought others might benefit from my findings, as I wasn’t able to find any complete configuration tutorials.

I was able to replicate the functionality I enjoyed from SuPHP (per directory php.ini configurations) with a simple wrapper script that’s called using an “Action” parameter in the .htaccess file.

To start, you’ll need to run EasyApache:
I have disabled “Mod SuPHP” from the easyapache configuration and enabled “Mod FCGID”. This was the only change required to enable FastCGI support using the system php.ini configuration.

I reviewed many forum posts on the topic of local php.ini configuration with fcgid, but none really focused on the per-user aspect and how it can be user definable. I accomplished this with a very simple wrapper script for php-cgi that sets the PHPRC shell variable to the desired path, then a handler and action in .htaccess to call the script for handling php files. This allows for different directories to use different php.ini configurations by creating a different wrapper for each php.ini required.

First, edit the wrapper with your favorite text editor:
nano -w ~/public_html/php5.fcgi
Note, the name is arbitrary, but it needs to be in cgi-bin. Add the following code:
export PHPRC
exec /usr/local/cpanel/cgi-sys/php5

Then save, and make it executable:
chmod 755 ~/public_html/php5.fcgi

Next, you need to associate it with .php (and any other you’d like) extensions. Add these two lines to ~/public_html/.htaccess (or any .htaccess file)
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php5.fcgi

You can add additional extensions to the AddHandler line like so:
AddHandler php5-fastcgi .php .phtml .html

Update: The above instructions will break subdomains and addon domains if a separate php5.fcgi is not placed in each sub/addon cgi-bin folder. To combat this, I’m using a system accessible php5.fcgi that sets PHPRC to ~/public_html/. To do the same:
nano -w /usr/local/cpanel/cgi-sys/php5.fcgi
Then add this code:
export PHPRC
exec /usr/local/cpanel/cgi-sys/php5

Set permissions correctly:
chown root:wheel /usr/local/cpanel/cgi-sys/php5.fcgi
chmod 755 /usr/local/cpanel/cgi-sys/php5.fcgi

Finally, change .htaccess to use the new path:
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-sys/php5.fcgi

That’s it. It’s generic, can be copied to any user account without modification, and uses system configs for fcgid options, so it can use sane defaults.

I’ve uploaded my cpanel3-skel folder with perms set in case you would like to use it on your server.  Click here.

Helius reports in the comments that the steps above can break Fantastico on the server. To correct this, you’ll need to build cPanel’s PHP:
Thanks for the info Helius!

Ghost 4 Linux complete guide to imaging

About a month ago I was given 65 new Dell Optiplex 745’s to replace my 6 year old desktops in my training environment. This presented a multitude of problems for me.


  1. Our imaging software ran off of a floppy disk.
  2. It was DOS based, and I hate DOS
  3. It couldn’t detect SATA drives (you would not believe how mad I was when I finally solved the floppy problem just to run into this).

As usual, I’m dumped into this with no support of note and a limited time frame. Not to mention all of my normal duties. So what do I do? The same thing I do whenever I have an insurmountable obstacle… Turn to Linux.

Ghost 4 Linux is a CD based distro designed with imaging in mind. It’s really useful and all that, blah blah blah. This post isn’t about extolling its many virtues. This post is to teach you how to use it. More accurately, this post is to teach my coworkers at our other sites to replicate my setup. I’ve included below the document I sent to them so they could get up and running with Windows 2003 servers.


Ghost 4 Linux instructions

Ghost 4 Linux is natively a CD based distribution; however it can be easily modified to run from a network boot. These instructions assume you are using a Windows 2003 Server for DHCP.
Continue reading Ghost 4 Linux complete guide to imaging

Back from Orlando

I spent the last week in Orlando, FL on a business trip.  I drank more than anyone else and met a lot of really awesome people who I look forward to working with in the future.  I also met someone who I hope will remain a really good friend.  To all my readers/coworkers who were there, thanks much for the wonderful times.  It will not soon be forgotten.


I’ve been in Quantico for four days now.  Yesterday I was actually on base until 11pm.  Needless to say, training has me a bit tired this week, lol.

In other news, I’m trying yet another method for blocking spam.  After this comes completely disabling trackbacks and putting a captcha on comments.  That will at least make sure the spammers are human before they get to be seen on my homepage.

If any of you bastard spammers actually read this thing, could you just make a temporary screen name and message me?  My screen name is RedPicasso and I’d really like to discuss a few things with you.  It’ll be like the movie Enemy Mine, except there’s no way in fuck I’m going to try to learn your language.

I actually wonder if you speak any language at all.  If you were intelligent at all, I know you’d find a job to make money and not spend all day every day harassing people who just want to share tidbits of their life.  You’re pathetic.  What you do is akin to putting stickers on people’s cars in parking lots advertising things that have nothing to do with cars or parking lots.  Do you really think my readership gives a flyng fuck about penis enlargement (half my regulars are chicks dude…), cheap airline tickets (heard of, or internet gambling (here, let me give you money I don’t have so you can put spyware on my computer)?  It’s retarded, really.

Meh, I’m too disgusted to continue.  Time to get some training in.

Heading out!

Leaving now for VT…  I may post on the road, depending on how bored I get.  Time to pack now though, so I’m going to make this short.

Lessons learned this week:

  1. My boss likes me ALOT.
  2. I’m getting a raise sooner, rather than later.
  3. My boss likes drunk bowling almost as much as I do.
  4. Choke holds hurt the next day more than when they’re happening.

Yeah, that’s it.