FastCGI for PHP in Apache2

Hi All,

I'm new to VPS and have an issue. I'm trying to setup FastCGI to run PHP files for Apache2. I'm trying to setup a Joomla site and have no knowledge of nginx so I've stayed away from it. I can't see to find a tutorial on how to setup FastCGI.

I found a couple tutorials online but they seemed incomplete. Each time when I finished, I was getting 500 server errors for PHP files. I haven't been able to get PHP5 to work either.

I'm running Debian 5. Does anyone know of a tutorial that is good to setup FastCGI?

7 Replies

This guide may be helpful: http://library.linode.com/web-servers/n … an-5-lenny">http://library.linode.com/web-servers/nginx/php-fastcgi/debian-5-lenny

Thanks. I saw that but also saw it said Nginx. May I still use it as described for Apache?

Sorry about that, I saw "nginx" in your post and my mind jumped to the nginx/PHP-FastCGI guides :). This guide is for running PHP apps as CGIs under Apache on Debian: http://library.linode.com/web-servers/a … an-5-lenny">http://library.linode.com/web-servers/apache/php-cgi/debian-5-lenny

Is there a particular reason you're specifying FastCGI, or will your applications work under the commonly-used Apache/mod_php combination?

I'd just read that FastCGI is faster than CGI. If you disagree or think the difference is marginal then I'm all for doing what's easy.

The tutorials in the library are quite useful, by the way.

FastCGI (more information here: http://www.fastcgi.com/drupal/) is faster than plain "old fashioned" CGI because there's no need to spawn a new copy of the interpreter each time a script is run. However, to take advantage of this, applications need to be written as FastCGI apps (you can use wrappers to execute "plain" scripts under FastCGI as well).

It should be noted that modphp, modperl, and other modules exist to solve the same problem of having to load an interpreter for each script request. In all likelihood, if you're running Apache, mod_php will serve your needs just fine. Our Debian LAMP guide covers setting up a web server in this fashion: http://library.linode.com/lamp-guides/debian-5-lenny/

Thanks for the compliments on the Library :).

@pparadis:

It should be noted that modphp, modperl, and other modules exist to solve the same problem of having to load an interpreter for each script request. In all likelihood, if you're running Apache, mod_php will serve your needs just fine. Our Debian LAMP guide covers setting up a web server in this fashion: http://library.linode.com/lamp-guides/debian-5-lenny/

At the expense of wasting memory, sure. mod_php will load PHP into every single Apache process even if they're serving up static content.

> At the expense of wasting memory, sure. modphp will load PHP into every single Apache process even if they're serving up static content.
It's important to look at a site's actual requirements and understand the tuning options available in Apache before deciding to throw mod
php out over something like this. Many high traffic sites use it without any issues, and the actual traffic expected on a site should be taken into consideration, with load testing, before making such a call.

If optimizing the memory footprint and overall performance is critical, it's always possible to offload static content to something else, such as nginx or another web server daemon, without having to use it for everything. This has also been a common practice for high traffic sites.

Edit/addition:

For sites with very high traffic, it is often highly desirable that they be hosted on more than one web server for traffic management and redundancy purposes. One method of accomplishing this is discussed here: Build a Highly Available HTTP Load Balancer on Ubuntu 10.04 LTS (Lucid)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct