News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Ben_S - How do you have APC configured ?

Started by Niteblade, June 12, 2006, 08:39:29 PM

Previous topic - Next topic

Teckinno

#40
Quote from: guice on June 29, 2006, 12:19:01 PM
Quote from: Teckinno on June 26, 2006, 09:27:47 PM
There are no errors in the error_log, the file is empty. :)
Ok those are the final mods... APC is blasting my site like crazy, lightning fast.

File php.fcgi
---
#!/bin/sh
export PHP_FCGI_CHILDREN = 3
exec /home/dreamhostuser/local/bin/php
I really don't see how your apc is working with this. For starters, your php.fcgi file has syntax errors in it. sh does not understand setting and exporting a variable on the same line. That's bash. For sh you need to separate them out onto their own lines. Second, neither bash or sh allow spaces before or after the '='.

Now, the premise doesn't work either. When you start up the sh script, it runs it as an "sh" shell script, spawning off a new PHP process in it's own memory space, completely unrelated to apache. Which means, php is not running as fast-cgi. The sh script is, but php is not. I even tested out APC with this setup and it does not cache. I DO see 3 php processes run and then stop, however APC does not retain a cache.
You got me on this, your post makes a lot of logic. Let us know what we should change in the php.fcgi file.
Btw, the above php.fcgi file was posted at the dreamhost wiki site, by one of the DH devs.

I will edit the file php.fcgi like that:
--
#!/bin/sh
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /home/dreamhostuser/local/bin/php

and the .htaccess file like that:
---
<Files "php">
   SetHandler fastcgi-script
</Files>
Action fastcgi-file /cgi-bin/php.fcgi
AddHandler fastcgi-file .php

EDIT: Look at this, it's working perfectly:
http://www.adolympics.com/apc.php [nofollow]

File php.fcgi  edited and chmoded to u+x. Do you recommend anything else to be done?
Also, can you have a solution for the $_SERVER['PHP_AUTH_USER'] login, when you run PHP as CGI?
Thanks.

PS. You can get a complete list of timezones here:
http://www.php.net/manual/en/timezones.php [nofollow]

Niteblade

Quote from: guice on June 29, 2006, 02:20:50 PM
Why is my stuff being debugged? lol ..

Heh. Yeah, well, you're smart when it comes to this, and I'm not. I figure that I can "see" what's happening when it's all laid out before me. :) Thanks for being so patient.

Found this thread, figured that someone else can translate it and possibly apply the information herein to DH ... http://forum.mamboserver.com/showthread.php?t=50867 ...

Also found http://support.tigertech.net/fastcgi ...
QuoteUsing FastCGI for PHP

You can also use FastCGI to run PHP scripts (in fact, this is probably the most common use). To run PHP scripts via FastCGI, you need to install a "wrapper" program and add two lines to the .htaccess file at the top level of your site.

Tiger Technologies can set this up for you if necessary, so if you don't understand the instructions below, just contact us at [email protected] and we'll take care of it.

The wrapper script must be placed at the top level of the Web site, must be mode 0755, and must be named "php-fastcgi.fcgi" (this special name is exempt from subdomain rewriting and therefore works properly in an "Action" handler for a subdomain). The contents of the file should be these four lines:

    #!/bin/sh
    ulimit -t 3600
    ulimit -v 100000
    exec /usr/bin/php4-cgi -c /etc/php4/cgi/php-fcgi.ini

After creating that file, the following two lines must be added to the site's top-level .htaccess file:

    AddHandler  php-fastcgi   .php
    Action      php-fastcgi   /php-fastcgi.fcgi

That overrides the normal handling of PHP files, running them via the "wrapper", which in turn is run by FastCGI because it has a name ending in .fcgi.

After I read that, even though I don't understand what the ulimit -v 100000 or ulimit -t 3600 commands do, I put this inside my php5.fcgi file ...

php5.fcgi

#!/bin/sh
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
ulimit -t 3600
ulimit -v 100000
exec /home/nite/php/bin/php -c /home/nite/php/etc/php/pennyquick.com


.htaccess

<Files "php">
  SetHandler fastcgi-script
</Files>
Action fastcgi-script php5.fcgi
Action pennyquick-php /cgi-bin/php.fcgi
AddHandler pennyquick-php .php .pcgi


And I decided to get a little crazy and experiment around with the latest development edition of APC, v3.0.11 ...
http://www.pennyquick.com/apc.php ...

** awaits to be criticized for his frankenstein-like php experiments **

affiliate blog

Niteblade

This happens


FastCGI: comm with (dynamic) server "/home/****/pennyquick.com/cgi-bin/php5.fcgi" aborted: (first read) idle timeout (120 sec)

FastCGI: incomplete headers (0 bytes) received from server "/home/****/pennyquick.com/cgi-bin/php5.fcgi"


when .htaccess looks like this :


<Files "php">
  SetHandler fastcgi-script
</Files>
Action fastcgi-script php5.fcgi
Action pennyquick-php /cgi-bin/php5.fcgi
AddHandler pennyquick-php .php .pcgi

affiliate blog

franklinrony

i get the same error and in process dont show php.fcgi process i use dreamhost
http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

Something like that

Quote from: frony on October 21, 2007, 11:57:12 PM
i get the same error and in process dont show php.fcgi process i use dreamhost
Quote from: frony on October 21, 2007, 11:57:12 PM
i get the same error and in process dont show php.fcgi process i use dreamhost

I'm also currently on Dreamhost, and their shared hosting package is not well suited for using APC. Dreamhost has a per user limit of 100 MB of RAM usage, and if your user exceeds that, their process killer will randomly kill processes. That includes the fast-cgi PHP processes. Each PHP process with APC will use around 10 MB to start, plus the cache size -- for each process! A decent cache for APC will be about 10 MB or more -- so that really limits you to about 4 processes. And if you exceed that, your fast-cgi process will be killed, and APC will have to rebuild the cache! That doesn't sound bad, and it wouldn't be, except that you have to wait for database queries to return. Don't waste your time trying to get APC working with their shared hosting. I tried _everything_.

franklinrony

thanks i see is very bad dh to cache accelleratos install eaccelerato but dont work fine :( . any good shared host to support apc or similar?
http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

Something like that

Quote from: frony on October 26, 2007, 08:00:52 PM
thanks i see is very bad dh to cache accelleratos install eaccelerato but dont work fine :( . any good shared host to support apc or similar?

None that I'm aware of. And there probably aren't any. For APC to work optimally, PHP needs to be run as an Apache module (and almost all shared hosts use Apache). However, few shared hosts run PHP as a module because of CPU time abuses, and even if so, you wouldn't be able to compile your own PHP (with APC) for use as an Apache module. You really need to move to a VPS solution.

Deaks

~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

franklinrony

well i have  a ps account and now work fine the apc accelelrator :) must be the memory limit the procees kill
http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

Advertisement: