Advertisement:

Author Topic: Ben_S - How do you have APC configured ?  (Read 23952 times)

Offline Teckinno

  • Semi-Newbie
  • *
  • Posts: 14
Re: Ben_S - How do you have APC configured ?
« Reply #40 on: June 29, 2006, 05:24:07 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]
« Last Edit: June 29, 2006, 07:14:36 PM by Teckinno »

Offline Niteblade

  • Full Member
  • ***
  • Posts: 662
  • Gender: Male
    • Prosperent Ads
Re: Ben_S - How do you have APC configured ?
« Reply #41 on: June 29, 2006, 07:15:51 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 ...
Quote
Using 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 support@tigertech.net 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
Code: [Select]
#!/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
Code: [Select]
<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

Offline Niteblade

  • Full Member
  • ***
  • Posts: 662
  • Gender: Male
    • Prosperent Ads
Re: Ben_S - How do you have APC configured ?
« Reply #42 on: June 29, 2006, 07:44:00 PM »
This happens

Code: [Select]
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 :

Code: [Select]
<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

Offline franklinrony

  • SMF Hero
  • ******
  • Posts: 1,958
  • Gender: Male
  • Sharedownload SEO
    • franklinrony on Facebook
    • @franklinrony on Twitter
    • share download
Re: Ben_S - How do you have APC configured ?
« Reply #43 on: October 21, 2007, 11:57:12 PM »
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----

Offline Something like that

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,496
  • Gender: Male
  • ]
Re: Ben_S - How do you have APC configured ?
« Reply #44 on: October 25, 2007, 11:23:26 PM »
i get the same error and in process dont show php.fcgi process i use dreamhost
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_.

Offline franklinrony

  • SMF Hero
  • ******
  • Posts: 1,958
  • Gender: Male
  • Sharedownload SEO
    • franklinrony on Facebook
    • @franklinrony on Twitter
    • share download
Re: Ben_S - How do you have APC configured ?
« Reply #45 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?
http://twitter.com/franklinrony

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

Offline Something like that

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,496
  • Gender: Male
  • ]
Re: Ben_S - How do you have APC configured ?
« Reply #46 on: October 26, 2007, 11:21:18 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.

Offline Deaks

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,158
  • Gender: Male
Re: Ben_S - How do you have APC configured ?
« Reply #47 on: December 08, 2007, 04:45:21 PM »
can i ask if this is sorted or not :)

Offline franklinrony

  • SMF Hero
  • ******
  • Posts: 1,958
  • Gender: Male
  • Sharedownload SEO
    • franklinrony on Facebook
    • @franklinrony on Twitter
    • share download
Re: Ben_S - How do you have APC configured ?
« Reply #48 on: December 08, 2007, 06:42:38 PM »
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----