Fast CGI + Custom PHP

Fast CGI + Custom PHP

Posted by: Tenstones
Posted on: 2008-10-16 17:26:00

I have had a custom install of php 5.2.6 running for a while now, but it just feels slow so I wanted to see if fast cgi would speed it up and I can't get it working for the life of me.

I followed the information in the wiki ( http://wiki.dreamhost.com/PHP_FastCGI )

My wrapper is named dispatch.fcgi and contains:

#!/bin/sh
export PHPRC=/home/tenstone/tenstones.net/cgi-bin
export PHP_FCGI_CHILDREN=3
exec /home/tenstone/tenstones.net/cgi-bin/php.cgi


My .htaccess is:

Options +ExecCGI
#Action php-cgi /cgi-bin/php.cgi
#AddHandler php-cgi .php
AddHandler fastcgi-script fcg fcgi fpl
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/dispatch.fcgi



<FilesMatch "^php5?\.(ini|cgi)$">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
</FilesMatch>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats|failed_auth\.html).*$ [NC]
RewriteRule . - [L]
</IfModule>


ErrorDocument 404 /forums/404.php


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !forums/
RewriteCond %{QUERY_STRING} !vbseourl=
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ forums/vbseo.php?vbseourl=$1&vbseorelpath=../&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|redir\.php|vbseo_sitemap|autotagger_ajax\.php|404\.php)

RewriteCond %{REQUEST_FILENAME} !forums/
#RewriteRule ^(.*\.php)$ forums/vbseo.php?vbseourl=$1&vbseorelpath=../&%{QUERY_STRING} [L]


Like the wiki page says I get no response when I update the .htaccess and the error.log says:

[Thu Oct 16 16:20:47 2008] [error] [client 74.6.22.88] FastCGI: comm with (dynamic) server "/mnt/local/home/tenstone/tenstones.net/cgi-bin/dispatch.fcgi" aborted: (first read) idle timeout (60 sec)
[Thu Oct 16 16:20:47 2008] [error] [client 74.6.22.88] FastCGI: incomplete headers (0 bytes) received from server "/mnt/local/home/tenstone/tenstones.net/cgi-bin/dispatch.fcgi"


I tried touch dispatch.fcgi like it says and still nothing shows up when I do a ps.

How my main domain is stuck with a 503 error while the subdomains work and the error.log is spammed with:
[Thu Oct 16 17:18:51 2008] [error] [client 76.236.96.241] access to /info.php failed for 76.236.96.241, reason: Client exceeded concurrent connection limit of 20

Changing back the .htaccess has no effect.

Tenstones Gaming Community

Re: Fast CGI + Custom PHP

Posted by: sXi
Posted on: 2008-10-17 00:39:00

Did you try it without the FilesMatch section?


Re: Fast CGI + Custom PHP

Posted by: Tenstones
Posted on: 2008-10-17 09:36:00

No luck there. Still can't get the fcgi to start no matter how much I touch it.

Same error in the log.
[Fri Oct 17 09:30:40 2008] [error] [client 74.6.22.90] FastCGI: comm with (dynamic) server "/mnt/local/home/tenstone/tenstones.net/cgi-bin/dispatch.fcgi" aborted: (first read) idle timeout (60 sec)
[Fri Oct 17 09:30:40 2008] [error] [client 74.6.22.90] FastCGI: incomplete headers (0 bytes) received from server "/mnt/local/home/tenstone/tenstones.net/cgi-bin/dispatch.fcgi"

Tenstones Gaming Community

Re: Fast CGI + Custom PHP

Posted by: sXi
Posted on: 2008-10-17 10:04:00

Yeah that's weird. Especially the 20+ connections when requesting info.php once.


This is a real stretch, but did you dos2unix the files you edited?
eg. $ dos2unix ~/tenstones.net/cgi-bin/dispatch.fcgi

And just out of curiousity, what does $ uname -a report?


Re: Fast CGI + Custom PHP

Posted by: Tenstones
Posted on: 2008-10-17 10:16:00

Linux dalitz 2.6.24.5-serf-xeon-c6.1-grsec #1 SMP Tue Oct 7 06:18:04 PDT 2008 x86_64 GNU/Linux

Just tired the dos2unix and it still wouldn't start the process.

Tenstones Gaming Community

Re: Fast CGI + Custom PHP

Posted by: Tenstones
Posted on: 2008-10-17 11:33:00

I think I got it working...?

I disabled FastCGI in the control panel and reenabled it. I'm not getting any erorrs, but I don't see anything when I do a $ ps either?

[dalitz]$ ps
PID TTY TIME CMD
18408 pts/8 00:00:00 bash
22683 pts/8 00:00:00 ps
[dalitz]$ ps -ef
UID PID PPID C STIME TTY TIME CMD
tenstone 4227 4115 0 09:31 ? 00:00:00 sshd: tenstone@notty
tenstone 4241 4227 0 09:31 ? 00:00:00 /usr/lib/openssh/sftp-server
tenstone 5333 5219 0 11:22 ? 00:00:00 sshd: tenstone@pts/9
tenstone 5364 5333 0 11:22 pts/9 00:00:00 -bash
tenstone 11532 11438 0 09:51 ? 00:00:00 sshd: tenstone@pts/4
tenstone 11546 11532 0 09:51 pts/4 00:00:00 -bash
tenstone 12007 11897 0 11:26 ? 00:00:00 sshd: tenstone@notty
tenstone 12017 12007 0 11:26 ? 00:00:00 /usr/lib/openssh/sftp-server
tenstone 18379 18203 0 11:29 ? 00:00:00 sshd: tenstone@pts/8
tenstone 18408 18379 0 11:29 pts/8 00:00:00 -bash
tenstone 18666 18582 0 10:53 ? 00:00:00 sshd: tenstone@pts/5
tenstone 18673 18666 0 10:53 pts/5 00:00:00 -bash
tenstone 19902 18673 0 10:54 pts/5 00:00:00 /home/tenstone/tenstones.net/cgi
tenstone 20331 19923 0 09:21 ? 00:00:00 sshd: tenstone@pts/7
tenstone 20337 20331 0 09:21 pts/7 00:00:00 -bash
tenstone 22412 22339 0 10:55 ? 00:00:00 sshd: tenstone@notty
tenstone 22435 22412 0 10:55 ? 00:00:00 /usr/lib/openssh/sftp-server
tenstone 22615 27625 0 11:30 ? 00:00:00 /home/tenstone/tenstones.net/cgi
tenstone 22616 22615 11 11:30 ? 00:00:00 /home/tenstone/tenstones.net/cgi
tenstone 22617 22615 0 11:30 ? 00:00:00 /home/tenstone/tenstones.net/cgi
tenstone 22618 22615 0 11:30 ? 00:00:00 /home/tenstone/tenstones.net/cgi
tenstone 22740 18408 0 11:30 pts/8 00:00:00 ps -ef


Tenstones Gaming Community

Re: Fast CGI + Custom PHP

Posted by: sXi
Posted on: 2008-10-17 12:43:00

I was under the impression the checkbox in Panel didn't actually do anything other than report back to base that "Hey, this user is using fast cgi - chalk another one up on the scoreboard" or something of that nature.


Tags: fcgiphp cgifpladdhandlerphp 5htaccesscgi binexec