Ben_S - How do you have APC configured ?

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

Previous topic - Next topic

Niteblade

#20
I have successfully installed aPC with Dreamhost.

The steps : http://www.pennyquick.com/forum/index.php?board=5.0
The test : http://www.pennyquick.com/apc.php

Edit : I'm hovering between APC and eA. PHP v5.1.4 run as FASTCGI with APC v3.0.10 causes a 500 error when I attempt to backup the database through the admin menu of the forum software. However, PHP v5.1.4 run as FASTCGI with the latest CVS of eA does not cause the 500 error -- I can backup just fine.
affiliate blog

Teckinno

#21
Good job, I will check it tonight. :)
What PHP compilation script you used, the one posted on your forums?
Because Dreamhost have already installed those extensions:
M4="m4-1.4.4"
LIBTOOL="libtool-1.5.22"
AUTOCONF="autoconf-2.59"
AUTOMAKE="automake-1.9.6"

Just making sure...

Niteblade

Quote from: Teckinno on June 20, 2006, 06:46:09 PM
Good job, I will check it tonight. :)
What PHP compilation script you used, the one posted on your forums?
Because Dreamhost have already installed those extensions:
M4="m4-1.4.4"
LIBTOOL="libtool-1.5.22"
AUTOCONF="autoconf-2.59"
AUTOMAKE="automake-1.9.6"

Just making sure...

Yes; everything you see on my forum is exactly what I used to install my custom php with apc. I didn't think dreamhost had m4, autoconf, and automake as modules ? Anyhow, what you see on my forum is exactly what I used.
affiliate blog

Teckinno

#23
Use whereis m4 to see where is located the program.
I will try without them and let you know. :)

Niteblade

You might be interested to know something.

When APC v3.0.10 is stilled with PHP v5.1.4 running as fastcgi, I got a 500 error code when I attempted to backup my SMF database through the admin menu.

And this was what was in my error log :

[Fri Jun 23 17:35:43 2006] [error] [client 24.155.251.136] (104)Connection reset by peer: FastCGI: comm with server "/home/nite/pennyquick.com/cgi-bin/php.fcgi" aborted: read failed

[Fri Jun 23 17:35:43 2006] [error] [client 24.155.251.136] FastCGI: incomplete headers (0 bytes) received from server "/home/nite/pennyquick.com/cgi-bin/php.fcgi"


However, when I use the latest CVS build of eA, I didn't get the 500 error code -- everything worked like it was supposed to.

So, in my mind, it looks like there is a triangular problem ... (A.) - PHP v5.1.4 (B.) FASTCGI (C.) APC v3.0.10 ... I don't know which of the three is the root of the problem ...

Moreoever, the CVS build of eA "feels" snappier than APC. I don't know if that's just a psychological perception I'm having after changing ... (ya, I emptied out my broswer's cache...)
affiliate blog

Teckinno

#25
Use APC, it's heavy supported by the PHP guys.
Also, your tutorial is good. However, I use one .htaccess file with the following content:
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

AddHandler fastcgi-file .php
Action fastcgi-file /cgi-bin/php.fcgi
...

and a php.fcgi file with:
#!/bin/sh
export PHP_FCGI_CHILDREN = 4
exec /home/dreamhostuser/cgi-bin/php.cgi

I'm still working on refining my own procedure, so far APC is running smooth.
One thing, I need to know how to get the latest APC CVS, where is the link/page? The only thing that I don't like is the fact that I cannot use Zend Optimizer toghether with APC... I will use IonCube Loader instead, it works with APC.
Thanks.

Niteblade

Thanx for the props... I've got a thread going on the DH forums, as well. I think all of us need to send in a petition to DH to have them include such information in their monthly newletters.

BTW, what does this do ?

Options +FollowSymLinks +ExecCGI


And be sure to check your error logs in the directory outside your site's directory ... I don't know if there's still work to be done on our end or on DH's end.

When you discover an awesome way of doing your .htaccess, lemme know so that I can update my guide. I know absolutely nothing about "why" it works... but I can deduce from the logic of other working .htaccess files. But, for my sake, I would like to understand the "why" of it all.
affiliate blog

Niteblade

I suppose one *could* download each file in the linked directory, and put it inside a CVS directory for APC, and compile it like that. It seems that with APC, the programmers and coders update one file at a time, giving the user a selection as to which file versions of each individual file that they want to download. When I get home, I'll download the latest version of each file inside and attempt a custom compile just for the hay of it.

http://cvs.php.net/viewvc.cgi/pecl/apc/?pathrev=MAIN
affiliate blog

Teckinno

#28
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

File .htaccess
---
AddHandler fastcgi-script .fcgi
AddHandler fastcgi-file .php
Action fastcgi-file /cgi-bin/php.fcgi

RewriteEngine On
... more info ...

I used a totally different installer, that I made myself.
This is the PHP config:
---
sh ./configure --prefix=${PHP_DIR} \
--with-config-file-path=${ETC_DIR} \
--with-curl=${PHP_DIR} \
--with-freetype-dir=/usr \
--with-gd \
--with-gettext \
--with-iconv=${PHP_DIR} \
--with-imap=${PHP_DIR} \
--with-imap-ssl=/usr \
--with-jpeg-dir=/usr \
--with-libxml-dir=${PHP_DIR} \
--with-mcrypt=${PHP_DIR} \
--with-mhash=${PHP_DIR} \
--with-mysql=/usr \
--with-mysqli \
--with-openssl=/usr \
--with-pear-dir=${PHP_DIR} \
--with-png-dir=/usr \
--with-ttf=/usr \
--with-xml \
--with-zlib-dir=${PHP_DIR} \
--enable-bcmath \
--enable-calendar \
--enable-cli \
--enable-exif \
--enable-fastcgi \
--enable-force-cgi-redirect \
--enable-ftp \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-memory-limit \
--enable-soap \
--enable-sockets \
--enable-sqlite-utf8 \
--enable-trans-sid \
--enable-wddx

With the options set like that, PHP will run on Dreamhost like a dream. ;)
The install steps posted at DH site were wrongly selected, presenting security risks. Folders inside of the domain root containing vital PHP operating files? That's very bad. Plus it was a pain to copy files all over the sites. What do you do if you have multiple domains hosted, like I do? You have to copy a bunch of files... annoying... plus it would not work since you set by default only one domain to use PHP.
I made my install universal, to be ran for unlimited domains (one php.ini for all sites), the way it should be... with no files to be copied in the domains directories.
Also, I did not installed M4, AUTOCONF, AUTOMAKE, LIBTOOL, PCGCONFIG, etc. They are installed by default, on my server.

Not all DH servers have those tools installed. I was missing AUTOCONF and AUTOMAKE. One tech guy at DH installed them for me, saving me the trouble.
Those files are really pretentious, so I prefered to have them installed on the real ROOT, not mines.

Now I run APC and IonCube Loader for my encoded script.
I'm really happy since finally I managed to get everything work really smooth.

Your ideas helped me optimize everything, thanks for posting your info in the forums.
I guess that we have it all as a team effort. :)

Floren

Niteblade

#29
Would you mind contributing your installscript, your php.ini, and your .htaccess files on my site ? Or if you'd like, you could paste them here and I could move them over to my site... and give you props for 'em.
affiliate blog

Teckinno

As soon as my site is open, I will post a link to the detailed steps I used.

Niteblade

Have you figured out why APC seems to restart itself at random intervals ?
affiliate blog

Teckinno

#32
I'm sure it's the Apache server that is restarted or some DH script that cleans the server memory... resulting on APC reseting the values.
APC does not restart, it's simply not caching anymore the previous values.
There is nothing wrong with it, I actually set APC to clean itself every 2 hours, as recommended in the install file.

Maybe it's the high value we chose for the shared memory? I use 64MB.
You tried 32 or 16 and see if it's still cleaning the cache to 0?

This is my APC config:
; APC
extension = "apc.so"
apc.enabled = 1
apc.shm_segments = 1
apc.optimization = 0
apc.shm_size = 64
apc.ttl = 7200
apc.user_ttl = 7200

EDIT: Is definitelly related to a DH memory cleanup/optimization cronjob or something similar. I did a test and opened both apc.php files for my site and yours.
They got reset at the exact same time. :)

How did you TAR the CVS dev version for APC?
I think I will stick with the production version, it's working great on my site.
Tired of playing around... since we both got it working... and working well. :)

Another thing... can you log succesfully into the User Cache Entries?
It does not recognize my username/password, even if I change it manually in the apc.php file with my own values.

Niteblade

No, I can't get into that part.

You'll have to get another apc.php, and rename it to something like : admin_apc.php, hide it, and then edit out the code that calls for the password.
affiliate blog

Teckinno

#34
It's related to $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'].
The HTTP Authentication hooks in PHP are only available when it is running as an Apache module, not available in the CGI version. :(
This sucks... I will look into a solution.

EDIT: Ok, try this into your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}, E=PHP_AUTH_USER:%{HTTP:Authorization}, L]


Let me know if that solve it.

Niteblade

Internal server error with that code in htaccess.
affiliate blog

Teckinno

Here it is the trouble:
With PHP FastCGI/CGI, we need to use REMOTE_USER, instead of PHP_AUTH_USER.
That's why we cannot login, PHP_AUTH_USER/PW is not recognized.

Try to search Google for a solution, I will do the same.
I'm sure we can solve it, we are close. :)

guice

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.

Niteblade

#38
guice,

1. what are the exact and complete contents of your .htaccess file ?
2. did you simply place a copy of the php file located in the /home/dhuser/php/bin into your /home/dhuser/whatever.com/cgi-bin folder ?
affiliate blog

guice

Quote from: nite0859 on June 29, 2006, 02:02:22 PM
guice,

1. what are the exact and complete contents of your .htaccess file ?
2. did you simply place a copy of the php file located in the /home/dhuser/php/bin into your /home/dhuser/whatever.com/cgi-bin folder ?

1 - Nothing different than anybody else
<Files "php">
  SetHandler fastcgi-script
</Files>
Action fastcgi-script php.fcgi
Action gpcentre-php /php-cgi/php
AddHandler gpcentre-php .php .pcgi

(the fcgi part isn't being used at the moment as you can see.)

2 - No, it's a softlink to my PHP bin directory. That way I can update PHP with no change to the binaries.

Why is my stuff being debugged? lol .. As I stated above, the sh script has syntax errors. But, even after fixing the syntax errors, PHP is launched as a command line application, not by the web server within a fast-cgi wrapper. php.fcgi is launched as a fast CGI, but that in turn launches PHP into it's own memory space as a completely separate process, not within a fast-cgi wrapper.

Advertisement: