I am in the process of changing Hosts and have just been asked a question, I know nothing about.

On the new Host, I have the option of running PHP as CGI.

? Would this be a good thing or a bad thing?

I also have the option of using FastCGI, again, a good thing or a bad thing?

Thanks, for any information you can offer.

Comments

Samat Jain’s picture

There are various ways of running PHP scripts, in order of preference:

  1. mod_php
  2. FastCGI
  3. CGI

I'm ranking these in terms of performance.

With mod_php, the PHP interpreter is within the Apache process. You won't get faster than this.

With FastCGI, PHP runs as a "server" of sorts, that Apache will then connect to when a page is requested. This offers some versatility: you could run the server suid as your own user, and easily be able to create/manage files within your home directory.

With CGI, the web server process is fork()'ed for every page request, and a new PHP interpreter on each page request. This is slow and resource intensive, and not a good idea if you expect a decent amount of traffic.

__
My Drupal websites: Personal home page | Rhombic Networks: specialized Drupal application hosting

green monkey’s picture

Thanks Samat,

Thats helps me.

So, it looks like it is best just to run as is - PHP.

I was reading some of postings at the Host as well, and it seems there can be some type of .htacess issues as well with the CGI. I don't claim to understand what they were writing about.

Samat Jain’s picture

.htaccess files are read by Apache--any settings contained won't be applied to PHP running as a CGI or FastCGI.

You won't be (easily) be able to use URL rewriting either without use of mod_php.
__
My Drupal websites: Personal home page | Rhombic Networks: specialized Drupal application hosting

sito-1’s picture

Just following up on that last point, what are the not-so-easy steps to enable URL rewriting (I assume you meant clean URL?) when running PHP as a CGI? Thanks!

el777’s picture

I think it's not so difficult to enable clean urls and other features not in .htaccess but in httpd.conf

el777’s picture

I'm interesting in running PHP in FastCGI mode on my linuxbox. I looked through the docs and found it has some serious advantages:
1) Separation users from each other at the OS level. Each host has it's own user, so you can easily to constrain it's access to files on yuor hard drive. Enable quotas per user. Limit users by processes and CPU consumption.
2) According to several investigations fastcgi works much faster than mod_php and cgi mode.

killes@www.drop.org’s picture

I am running fastcgi and I am quite happy with it. None of my sites has a lot of traffic though.
--
Drupal services
My Drupal services

greggles’s picture

I too am using FastCGI on the two sites in my signature. They are also running PHP5.

They are low volume sites and I don't have statistics on whether performance is better one way or another. I'm on a shared host, but have shell access (Dreamhost, naturally) so if someone wants to tell me of a test (internal or external to Drupal) I'd be happy to try.

--
Wanderlusting Travelers
Knaddison Family

killes@www.drop.org’s picture

Do you have some urls with recipies for people hosting Drupal on dreamhost? Those often run Drupal as CGI and get into trouble for using a lot of CPU cycles.
--
Drupal services
My Drupal services

greggles’s picture

My recipe so far has been to stay low volume :)

Not much of a succesful recipe, of course.

I will say this on the subject: I currently have/support sites at 4 hosts right now and have used 1 more in the past. Of the five, I am happiest with Lunarpages and Dreamhost. Of those two, my sites in Dreamhost are the ones I experiment with/use/update the most - not because I need to but because they provide me shell access which makes life so much better. Find a patch you need to apply - done! With my FTP hosts this is much more difficult.

I have not had problems with the CPU limit. Also, they just raised it to 50 CPU minutes/day vs. the earlier level of 30-40.

At the price, I couldn't be happier. If I wanted to run a big volume site with complex features...I'd probably need a dedicated server. But if I did that, I'd have the donations/adsense revenue to cover it, right?

--
Wanderlusting Travelers
Knaddison Family

killes@www.drop.org’s picture

Well, there were so many problems with dreamhost that I took them out of a list of hosters that we have. I felt we should not recommend them. Maybe you are right and the people who had problems got what they paid for. ;)
--
Drupal services
My Drupal services

greggles’s picture

Like I said, I've used several hosters and Dreamhost is my favorite. One problem I had in the past was that occasionally someone on a shared server would have a script that brought the whole machine to its knees - the host wouldn't know who did it and everyone on the shared machine suffered (and complained in the forums until it got fixed). That's a "reactive" response whereas the Dreamhost philosophy is a "proactive" response of monitoring speed and quarantineng the offendors. They won't take the site down, just quarantine it and make you fix it or move to dedicated.

It also seems that they are upping their CPU:

CPU Minutes Limit at Dreamhost

There's also a pretty funny post about amp/cpu and why it's hard to add CPU power but in the end, as a customer I don't care much about the problem, I care about the solution, right?

It's a OT here, but possibly worth investigating shared hosting plans in general.

--
Wanderlusting Travelers
Knaddison Family