APC installed on Dreamhost? It was done...

APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-12 23:09:00

Hi all,

There is an article about APC being installed on Dreamhost:
http://blog.dreamhosters.com/2006/04/11/end-of-php-as-an-apache-module/

Someone stated that they actually installed sucessfully APC with Dreamhost.
As you know APC will dramatically increase your site performance and ease the server also. Read more here:

I compiled APC on DreamHost with no problems… I have my own PHP version compiled also with FastCGI enabled.
However, I don’t see APC info in the phpinfo file.

This is what I did so far:

[server]$ mkdir src
[server]$ cd src
[server]$ dir
[server]$ wget http://pecl.php.net/get/APC-3.0.10.tgz
[server]$ gunzip -c APC-3.0.10.tgz | tar xf –
[server]$ cd APC-3.0.10
[server]$ /home/dreamuser/local/bin/phpize
[server]$ ./configure –enable-apc –enable-apc-mmap –with-php-config=/home/dreamuser/local/bin/php-config
[server]$ make
[server]$ make install
[server]$ cp /home/dreamuser/local/lib/php/extensions/no-debug-non-zts-20050922/apc.so /home/dreamuser/local/lib

In php.ini, I added the following lines, under Dynamic Extensions:
; APC
extension = “apc.so”
apc.shm_size = 16

I should also define the --with apxs=/path/here option, but I don't know where is located the Apache server on cerritos.
If anyone managed to install it succesfully, please post your steps here.

Thanks.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-13 11:18:00

I don't know APC, but I can tell you two things I see wrong. One, you do not use --with-apxs. That's for the apache module API info. You're not using the Apache module.

Second, the command line options are wrong. They should start with -- not -. ie: ./configure –-enable-apc –-enable-apc-mmap –-with-php-config=/home/dreamuser/local/bin/php-config

Try that.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-13 20:54:00

They are 2 -, the post makes them look like one, due to the copy/paste. :)
I'm waiting on Dreamhost to post the apxs path for Apache 1.33.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-14 09:16:00

No, cause the original post only has one hyphon. Plus I copy/pasted the original post in my terminal window to check out the install instructions myself and there was only one hyphon. ^_^

Anyhow, I have successfully installed it on my server: http://www.gpcentre.net/info.php

No apxs. Like I said earlier, that's ONLY for the Apache Module. We're using PHP-CGI /not/ the Apache module.

The install instructions are correct to a point. It's incorrect on the hyphons. Should be two --, not -. And it's assuming you've installed PHP in $HOME/local.

My command line is this:
./configure --prefix=$HOME/php --enable-apc --enable-apc-mmap --with-php-config=$HOME/php/bin/php-config

I installed my PHP and all PHP related files into $HOME/php. I also added the --prefix option out of habit. I see in --help there is no --prefix option. ha

And it works. I do see a difference on the forums on my guild's site (uses the same PHP binary). The only thing I noticed is that it takes time for it to cache. Once it does all the cache, the speed is noticeable.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-16 19:44:00

Hi guice,

I'm familiar with the installs, but I might be worng.
This is what I did:
cd $HOME/source ; tar xzf $HOME/dist/APC-3.0.10.tgz
cd APC-3.0.10 ; $HOME/local/bin/phpize
./configure --prefix=$HOME/local --enable-apc --enable-apc-mmap --with-php-config=$HOME/local/bin/php-config

make
make install

It looks like it's installed, but it's not, the same like before.
Take a look:
http://www.adolympics.com/phpinfo.php

It looks like it's there and ready, right?
Well... is not working properly:
http://www.adolympics.com/apc.php

Refresh the page several times, you will see that the Start Time is always reset to Now (0 minutes).

A properly installed APC should look like this:
http://www.redandwhitekop.com/forum/apc.php

Let me know if you have any solutions. It might be something related to PHP compile steps? Thanks.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-16 20:31:00

Okay, I think I know the problem; because it's PHPCGI. I guess the APC cache is built for memory caching. Since PHPCGI runs once and shuts down, there is no memory retain the data.

That's odd, cause it does seem like the my forum's speed improved. ^_^
Guess not .. since I just disabled it and the forums are going the same speed. Maybe there was a significant speed boosts from PHP5.1.2 to PHP5.1.4. That or I did something in MY version to boost the speed when I installed it. /shrug

Sorry, but from the look of things, APC is a memory cacher and requires the use of mod_php for full proper use. And no, we do not have the ability to install that. Basically it means we're SOL and nothing we can do about it.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-16 22:11:00

Then I have to stick with eAccelerator... :(
Thanks for your help.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-19 15:14:00

Ok, I installed eAccelerator. Same results, it's caching only one script/page:
http://www.adolympics.com/phpinfo.php

Are we dealing with the same problem?
Thanks.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-19 16:25:00

Yup, looks like it.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-20 00:58:00

Guice, you have to find a solution.
We are talking about lowering the server load for many people.
That will result in an increased performance for all of us.
DH should install APC as default, it's supported by the PHP guys, it's not a cheap PHP mod.

Where could I develop the subject?
Could you put a good word with the support team? Thanks.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-20 08:33:00

Unfortunately, there's no much I can do. DH folks are moving away from mod_php to PHPCGI. These cache systems only work on mod_php. Not to mention that DH won't be using mod_php5. I don't recommend anybody going back to PHP4.

To be quite honest, it's stuck between a rock and a hard place now.

Let me ask around on other PHP sites to see if there's any other option. I don't know of any off hand. But reading from eAccelerator, it stores PHP's compiled state in memory. If there's a way to store that on a local file system, maybe there will be a way to use it between state.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-25 12:52:00

I've got both eA and APC working.

I've got a general set of instructions on my site; It worked for *me* on *my* site... I'm interested in knowing if what worked for me will also work for other people.

http://www.pennyquick.com/forum/index.php?board=5.0

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-25 13:57:00

Well, it installs, but it doesn't cache. And it can't by design. It caches the PHP compile code within shared memory. Because PHP CGI runs a new instance everytime you make a request, you get a whole new shared memory space each time.

Copy your apc.php file into a browsable location and take a look at it. You'll noticed the only think it'll have listed is itself.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-25 21:43:00

I came across that problem too at first. What I was saying was that I solved that problem; APC works 100%. EA works 100%. You'll see a nice little graphic with APC displaying the number of files that it has cached. (The uptime increases; the number of cached scripts increases.) EA doesn't have that nice graphics -- it simply tells you the number of cached scripts, with the file ' control.php ' ...

The secret is changing your .htaccess and renaming your php.cgi. That is, assuming that all the pre-requisite modules were downloaded and installed... such as m4, autoconf, and automake.

You have to change php5.cgi or whatever it's named to php5.fcgi ... PLUS you have to tell .htaccess to run all scripts as fast cgi by adding a couple of lines to it. And, in .htaccess, you must reference the php5.fcgi or php.fcgi or whatever it's named.

Then you'll see that it is working.

I promise that it's working. I know that it's working. I can verify that it's working. And I'll prove that it's working. I'll send you a link in a PM or something.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-25 21:44:00

In fact, just for you, I'll change over to APC for a little while. And I'll post a link for *EVERYONE* to verify. Give me about 5 minutes, and I'll come back here and post a link ...

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-25 22:06:00

Okay, I de-activated eA and put APC back on, but the server is being stubborn by keep eA in memory ... so it looks like I need a server reboot or something. But .. just in case, I'll give you two links.

1: eA ... http://www.pennyquick.com/control.php
2. APC ... http://www.pennyquick.com/apc.php

I don't know which one will be active; I did edit my php.ini to activate APC, however, at the time of this post, eA still showed to be doing its thing.

You can check the server status, too ...

Status : http://www.pennyquick.com/status.php
or even see my php config ...
http://www.pennyquick.com/status.php?php

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-26 05:54:00

APC is up.

Please post back here to confirm.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-26 08:56:00

Interesting. Very nice. It does work! In case people don't know the required entries for .htaccess, here are mine:

In reply to:

<Files "php">
SetHandler fastcgi-script
</Files>
Action gpcentre-php php-cgi/php
AddHandler gpcentre-php .php .pcgi


That works; it is caching: http://crescent.gpcentre.net/apc.php !

Nice call nite. Didn't think to set type to fastcgi for it to start up. Didn't even think there was a difference between the two. ^_^

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-26 16:20:00

I think this information ought to go out with the next news letter ... that way, everyone on the shared server can benefit from it.

By the way, be sure to check your error logs. It seems there's still work to do on either our end with APC, or on Dreamhost's end to properly allow for APC.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-26 16:31:00

Do you have CPU resources enabled on your account to see whether or not the accelerator makes a difference on the number of seconds that the CPU has to work ?

If there is a difference, then I think everyone ought to have an accelerator installed -- to make -everyone's- site speedier.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-26 21:55:00

No, I don't have it enabled.

And I see what you mean about the error:

In reply to:

FastCGI: server "/home/crescent/crescent.gpcentre.net/php-cgi/php" stderr: PHP Warning: date() expects parameter 2 to be long


It's too late now, but I'll do some research on it tomorrow to see if I can come up with anything.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-28 20:06:00

Is there something we're missing in .htaccess ?

We got a thread going @ http://www.simplemachines.org/community/index.php?topic=92967.0 as well ...

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 08:20:00

There's a server config error in the log file with date.time. That's easy to fix (below). However, the error above is a script error and not fixable except by the script itself.

Fix the timezone error:
Log onto your box, edit your php.ini and look for date.timezone. Uncomment it and set it to America/Los_Angeles.

THEN, in order to get PHP to see it: pkill -HUP php

That should clean up your logs. Btw, that post is an interesting read; however APC does not work using that php.fcgi sh file (Not to mention he has syntax errors). Keep it the way you had it (going directly to the binary itself) and you should be fine. Feel free to play with the APC settings posted. Each time you make a setting change, you'll need to send that pkill command again to insure PHP sees the config update.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 14:56:00

Thanks for the tips, we will get it working fine. :)
Let me edit the .htaccess file and create the soft link in /cgi-bin folder.
I will post here the results... in few minutes.

Ok, the soft link combination did not worked properly.

This is what I did to get it work:
File php.fcgi (chmod u plus x php.fcgi):

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 15:33:00

0.o ... I couldn't get the .fcgi script working, it kept using a new instance of PHP not in fcgi mode, which makes logical sense.

I'll have to play around with it again, once the server comes back up. /sigh ... No clue what happened. Just took a dump not 10 minutes ago recently.....

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 15:42:00

But it makes sense what I did?
I think is easier my way, when you have several domains to host.

The method you posted is this:
1. Create a /cgi-bin folder inside the /domain.com, chmod it to 751
2. Create a soft link to php exec in /cgi-bin
3. Edit .htaccess file:

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 16:57:00

Yup, makes complete sense. I see where my problem was. I had a rogue .htaccess file setting everything to cgi-script within my php cgi directory. ^_^

Removing that fixed it.

However, now I see another issue. Log into your server via shell and to a top. :)
It's creating 3 fcgi PHP processes for every Apache process. That's a lotta PHP processes. Don't know if I like that. I've also noticed it's created a unique APC cache or each PHP split. I can refresh apc.php and getting 3 different results.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 17:13:00

I'm working on a fix, as we speak. How do you see the 3 fcgi processes? Give me more details...

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 17:18:00

'top' will show running stats of all programs ran by your user.
'ps -ef | grep php' will show all process info that match 'php'.

I had it running only for short period on the server and I had at least 30 php processes running, totally bogging down the server. This is on a average trafficked site. That is not good at all. I immediately changed it back to point directly to the one php binary instead of the php.fcgi shell script.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 17:28:00

I see what you mean.
SO what we should do?

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 17:35:00

First thing's first, immediately revert from the php.fcgi script.
I'm checking out the ulimit stuff mentioned in the other thread. That's a resource limiter. Right now it's set to unlimited. The ulimit options set a limit to the resources. I'm seeing if I can break the server again with those options. ^_^

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 17:48:00

My site is new, not known to people. So far I did not break to many things... I hope. :)
Anyway, I'm thinking if we can do this:

If I have access to the httpd.conf, I should do this:
FastCgiServer /export/httpd/cgi-bin/php-fcgi
AddHandler php-fastcgi .php
<Location /cgi-bin/php>
SetHandler fastcgi-script
</Location>
Action php-fastcgi /cgi-bin/php-fcgi
DirectoryIndex index.html index.shtml index.cgi index.php
AddType application/x-httpd-php .php

Where php-fcgi is the copy or hardlink to the /bin/php file.
Work some magic and let me know. :)

Post your steps here, so we play with it...

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 18:28:00

Ok, I'm thinking out loud.
If PHP was compiled with option --enable-fastcgi, that means PHP is ran as fastCGI by default.
Look what I did... I copied /bin/php to /cgi-bin/php.fcgi
Then I did this .htaccess file:

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 19:15:00

Okay, I found out the issue with the multitude of processes was due to the PHP_FCGI_MAX_REQUEST being set to low. I changed it to 10000. Basically, php processes were hitting the MAX_REQUEST cap and restarting before the previous process could even finish itself out.

Throwing it up high will allow clean switch over.

I also did something, I have no clue what, that completely corrupted my original "php-cgi" path from being used in FastCGI. lol
No idea what I did, but the FastCGI server has a cow with File Not Found when I try to access a file from within "php-cgi". Changing the name fixed that problem. /boggle

The ulimit stuff, no clue if it has an effect, but I'll keep it in anyway. It's good to limit things like this, too.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 19:18:00

ha, nice work. I see your change. Yeah, I could do that, too. Although I think I really farked some things up. There's a few PHP processes I don't have access to running now. So I cannot kill them. ^_^

Anyway, you didn't haev to copy it to the php.fgi either. The extra processes were branches, perfectly normal. Read the README.Zeus file within the PHP Source. It explains what all the ENV variables mean.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 20:09:00

So, all I have to do is a symbolic link?
ln -s /home/dhuser/local/bin/php /home/dhuser/cgi-bin/php.fcgi

I just did that... everything is broken. Now if I revert to the old files, nothing is working.
I think i know the answer. Since we created a resource called php.fcgi, as long it existed, the system works.
If you drop it, everything is broke....

Let me know if you have other solutions... however, I read that is not recommended to do a soft link on the php exec.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-29 20:13:00

The server can't the symlink on the binary itself. If you want to run "php" as fastcgi, add the <Files "php"> thing mentioned earlier. That will force "php" to be ran as a fastcgi script.

This is what I have:
/home/me/php/php-cgi/php.cgi (sh script with the above)
/home/me/php/php-cgi/.htaccess (single line: SetHandler fastcgi-script

Then I go into my web directory and createa softlink to that directory:
ln -s /home/me/php/php-cgi /home/me/domain.com/php-cgi

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 20:46:00

Hmm... please post exacly the hole procedure, in details...
I'm getting confused. :)

Let me know if this is what you did:
Folder /cgi-bin:
.htaccess (one line SetHandler fastcgi-script)
php.fcgi file (copied from bin/php)

Folder domain.com:

.htaccess file:

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-29 22:54:00

maybe we should request that someone from dh come in here and help out.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-29 23:01:00

Wow, I got it working, php.fcgi is showing again in the resources list!!!
http://www.adolympics.com/apc.php

This is my .htaccess file in domain.com folder:

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-30 08:48:00

That load has to be from somebody else. One PHP process shouldn't be causing that.

I, too, just switched back to the single PHP process method. I didn't want, nor do I have the privileges, to deal with debugging the Apache server AND PHP processes to insure proper and stable execution.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-30 09:13:00

Odd.

When I do that ...

<Files .htaccess>
order allow,deny
deny from all
</Files>

<Files php>
SetHandler fastcgi-script
</Files>
AddHandler fastcgi-file .php
Action fastcgi-file /cgi-bin/php.fcgi

...

I see 4 php.fcgi processes spawning when I do the command "top" from my ssh (Telnet or Putty). And when I refresh my APC, I sometimes get what's being cached from processes 1, and sometimes I see what's cached from process 2, and sometimes I see what's cached from process 3, and sometimes, I see what's cached from process 4. Hence, I see 4 different "uptimes" with 4 different pages of file "hits" .

I'll attempt to read a little more closely what you did when I get off from work, but I swear I followed your example the first time.

And this ...
---- /domain.com (symlink to /cgi-bin here; .htaccess here)
...
symlink ? Does that make a short cut ?

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-30 10:50:00

If you're using the sh script, that's why. The sh script spawns off multiple processes to hand requests.

The problem I found is timing when a process reaches it's "MAX_REQUESTS" and a child spawn dies off. If your MAX_REQUEST is too low, children processes will spawn faster than they can die off.

Another issue that comes into play: When the process hits it's MAX_REQUEST, it dies and spawns a new process. The issue with this is that it then completely clears the cache.

It all depends on how fast you really want to clear your cache. Somebody like me runs a static code site, I'm more than happy to leave the cache going for hours and hours (days), but if the MAX_REQUEST is hit too quickly, the children processes die out and cache starts all over again.

That's why I kept with the single process method. That should work for now. I MAY go back to the three processes, if I can guarantee it'll be stable enough.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-30 11:46:00

I will not use this script:

#!/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

It's really bad, especially when you run several domains like me.
For each domain you wakeup with 3 or more resources asigned...
You can endup with 100 resources... brrr. Definitelly a NO GO.
The single call to php.fcgi is the way to go, definitelly.

I will test some new settings in the .htaccess file, to take care of the limit, without adding the extra resources:

<Files .htaccess>
order allow,deny
deny from all
</Files>

<Files php>
SetEnv PHP_FCGI_CHILDREN 3
SetEnv PHP_FCGI_MAX_REQUESTS 5000

SetHandler fastcgi-script
</Files>
AddHandler fastcgi-file .php
Action fastcgi-file /cgi-bin/php.fcgi

With those bold settings, I noticed an improved performance, not a big one, but definitelly one is there.
Try it on your board and let me know...
But I have a question. Do I really need the PHP_FCGI_CHILDREN setting? I don't think so, since I will always have 1 resource running...
I left on the htaccess file only this line:
SetEnv PHP_FCGI_MAX_REQUESTS 5000

for now... waiting feedback from you guys.

Nite, make sure you have this root structure:

-- /USERROOT
---- /cgi-bin
---- /domain.com
---- /local (your custom PHP folder)

Now, do this in your telnet window:

cp /home/dhuser/local/bin/php /home/dhuser/cgi-bin/php.fcgi
cd /home/dhuser/domain.com
ln -s /home/dhuser/cgi-bin cgi-bin

Put in your domain.com folder the .htaccess posted above.

That should take care of your problem. smile

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-06-30 12:55:00

Err, technically, the performance boost is from multiple processes running. ^_^

MAX_REQUEST just sets another time stamp for when a child process is to refresh itself.

Well see. I'll play with that data tonight. Thanks.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-30 15:28:00

Ooo, I like it, I like it. I see exactly one instance of php.fcgi running, and while it's consuming like 45% of the cpu load for my account, it's only consuming around 10% of the entire server load. Those numbers flucuate, though.

I'll be modifying my posts on my site to reflect what's working for me on my site ...

Didn't guice mention something about upping the value of PHP_FCGI_MAX_REQUESTS=5000 to 10000 or something in order to allow enough time for the process to begin, execute, then close without spawning another process or something like that ? It was a few posts back ...

P.S. : I'm sure that our close monitoring of our CPU loads will be appreciated by DH in general, as everyone using our methods on a shared server will benefit by snappier access to their sites.

P.P.S. : How many people can be online, with our current APC configuration, before the speed starts to drop, and the site in general that is running APC becomes noticably slower ?

P.P.P.S : How many sites are hosted on a single computer @ dreamhost ? 20 ? 50 ? 700 ?

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-30 15:30:00

There's a php file located on the SMF website, named status.php, that will allow other people to see some information ...

www.pennyquick.com/status.php

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-30 16:20:00

Moreover ...

With aPC, at least, when I attempt to backup my database through the admin menu of my forum software, SMF v1.1RC2, I get a 500 error. The error log reveals this :

(104)Connection reset by peer: FastCGI: comm with server "/home/****/pennyquick.com/cgi-bin/php.fcgi" aborted: read failed
FastCGI: incomplete headers (0 bytes) received from server "/home/****/pennyquick.com/cgi-bin/php.fcgi"

But when I was running eAccelerator, I didn't get those errors and the database backup function worked perfectly.

methinks aPC still has a little ways to go. Yes, I'm running the developer build (v3.0.11-dev) of aPC, but this also happened when I was running the v3.0.10 build.


Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-30 17:22:00

In reply to:

There's a php file located on the SMF website...


How can I get the status.php file? smile
Can you post a direct link? Thanks.

In reply to:

Didn't guice mention something about upping the value of PHP_FCGI_MAX_REQUESTS=5000 to 10000 or something in order to allow enough time for the process to begin, execute, then close without spawning another process or something like that ? It was a few posts back ...


There are people who use 500 for this value, 5000 is more then enough, I think.

In reply to:

With aPC, at least, when I attempt to backup my database through the admin menu of my forum software, SMF v1.1RC2, I get a 500 error.


NEVER do a database backup through a web admin, like your forums or any other web enabled device.
If your database is big, the browser will probably error and result in a corrupt .sql file.

Instead, use the right method: Telnet one.
I will post my procedure, using SecureCRT, the tool I use.
Here it is the original thread (if you don't have access, I paste it below):
http://www.vbulletin.org/forum/showthread.php?t=39558

BACKUP PROCEDURE
I assume that you already installed SecureCRT and configured correctly it's options, including the connection protocol, hostname, port and username. If you are not sure about any values, now is the time to contact your host and enquire this information.

01. Create a /backup folder in your ROOT, using your FTP client. Later on, you will need to know the path to that folder. If you are not sure how to get the path for your backup folder, create a info.php file with the content:
<?php phpinfo(32); ?>

Upload it into your backup folder and open it in your internet browser. Look for this information:
_SERVER["DOCUMENT_ROOT"] > /path/to/backup/folder

02. Login onto your server, using SecureCRT. You will see this information:
[USERNAME HOSTNAME]$ _

That means you are successfully logged in and ready do give commands, at the prompt.

03. At the prompt, type:
mysqldump --opt -u USERNAME -p DATABASENAME > /path/to/backup/folder/bk060502.sql

NOTE: Change the highlighted values with your own. You will need the MySQL database USERNAME that your web host created for you, NOT the one you access to your FTP server. In most cases, they are different.
If you are not sure, contact your host to obtain this information.
060502: month date year (easier to remember the last date you backup your database). Change it with the corresponding date of your actual backup.

04. You will be asked for your password:
Enter password: _

Enter your MySQL database PASSWORD and hit Enter.
NOTE: If you have a large database, it might take up to 20 minutes until your backup is done. Relax and smoke a cigarette or grab a snack.
When done, you will see in the SecureCRT window, the command prompt.

05. Login onto your FTP server and go to your /backup folder. You will see there your bk060502.sql file. Save it to a safe place (a CD-RW is good for me).

RESTORE PROCEDURE
Well, here it comes that day when your tables are corrupted and nothing works in your beloved vBulletin. If you would not had done a backup, you would probably hit your head against the wall because you lost all your 3845 members and 285,793 threads. Tables corruption can happen pretty often, even if MySQL is known for it's reliability.

01. Login onto your FTP server and upload your bk060502.sql file to your /backup folder.

02. Login onto your server, using SecureCRT. You will see this information:
[USERNAME HOSTNAME]$ _

That means you are successfully logged in and ready do give commands, at the prompt.

03. At the prompt, type:
mysql -u USERNAME -p DATABASENAME < /path/to/backup/folder/bk060502.sql

NOTE: Change the highlighted values with your own.

04. You will be asked for your password:
Enter password: _

Enter your MySQL database PASSWORD and hit Enter. When done, you will see in the SecureCRT window, the command prompt.

COMMON ERRORS
The most frequent error you might get is this:
ERROR 1045: Access denied for user...

There are 3 causes for this:
1. You didn't replace the "username" with the MySQL username assigned by your administrator.
2. You supplied the wrong password (usernames and passwords are case-sensitive).
3. You don't have access. Contact your administrator for more assistance.

NOTE: Since SecureCRT have all data encrypted, it's possible also to safely specify your password into the command line. I recommend not to do it, just to keep a good habit. In normal conditions, if you do so, it's very possible your password can then be viewed by others using your system.


Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-30 17:42:00

In reply to:

Err, technically, the performance boost is from multiple processes running. ^_^


I don't use the first bold line, only the second one.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-06-30 19:02:00

www.pennyquick.com/status.phps ...

It'll display as text inside your browser ... just copy and paste it inside a file name status.php ...

the SMF site is experiencing problems right now.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-06-30 22:29:00

The site started working again.
I uploaded the file to one of my domains.. is not working? Blank page... hmmm.
Is this a file designed to work toghether with your forum software?

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-07-01 07:16:00

I haven't tried it with anything else but my forum software.

All this talk about .htaccess, wrappers, and fast-cgi is paying off.

This is my CPU usage report from 06-30-06 :
Process CPU seconds user machine count average
php.fcgi 83.1000 50.063% 0.346% 87 0.955
php5.cgi 80.8600 48.714% 0.337% 293 0.276
php 0.7800 0.470% 0.003% 13 0.060
suexec 0.5800 0.349% 0.002% 200 0.003
top 0.5200 0.313% 0.002% 5 0.104
bash 0.1500 0.090% 0.001% 4 0.038
ln 0.0000 0.000% 0.000% 2 0.000
ps 0.0000 0.000% 0.000% 3 0.000
bash 0.0000 0.000% 0.000% 6 0.000
touch 0.0000 0.000% 0.000% 4 0.000
pkill 0.0000 0.000% 0.000% 5 0.000
grep 0.0000 0.000% 0.000% 4 0.000
dir 0.0000 0.000% 0.000% 1 0.000

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-07-01 08:21:00

According to the wiki ...

How do I back up my database?

To backup your MySQL database you can:
Use phpMyAdmin and use the options there to dump the contents to a text file.
From the shell, run this command: mysqldump --opt -uusername -ppassword -h yourMySQLHostname dbname > filename.sql

To restore your database from a backup:
Take that db dump and do: cat filename.sql | mysql -uusername -ppassword -h yourMySQLHostname dbname

...

Now, I would like to make a cron job that made a daily backup, and auto-renamed the backup filename to correspond to the month/day/year of the database file, and auto-delete more than the most recent weeks worth of backups. In other words, I want a cron job to backup only 7 days worth of databases.

Ideas on how to autoname the database ?

Ideas on how to auto-delete database backups more than 7 days old ?

EDIT:
Let's see what this says : http://wiki.dreamhost.com/index.php/Automatic_Backup
Edited by nite on 07/01/06 08:24 AM (server time).

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-07-01 08:26:00

^^ Not related to this thread. Please create a new thread with that question. :)

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-01 11:58:00

In reply to:

php.fcgi 83.1000 50.063% 0.346% 87 0.955


Your load is freaking high, your forums are not designed very well.
With my vBulletin forums I get a maximum of 5.0% 0.3%.

Anyway, let's keep the discussion on track, guice any results from your tests with the new APC settings I posted above?
I'm starting to switch myself all my sites to Apache 2.0, DH enable it for all sites now.
So far APC runs smoother on 2.0 then on 1.33
In case you want to know how I do it, is simple. I simply delete the domain in DH Control Panel and wait 1-2 hours, to make sure the DH Bot kills everything. Then I add it again the same domain.
The bot does not delete any of my files, so everything starts working in seconds, once the domain is re-added with Apache 2.0.

Example of a domain that I just added:
http://www.synergio.ca/apc.php

I don't have to erase or reprogram anything, related to APC or the actual PHP/domain files/folders.
So it's safe to keep all the actual PHP/APC configuration. Just letting you guys know.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-07-01 12:25:00

In reply to:

Anyway, let's keep the discussion on track, guice any results from your tests with the new APC settings I posted above?


No go. They actually don't make a difference. I used the child one, but only got 1 processes, even watching via top for any new PHP process spawns.

I think the performance increase you saw was a placebo effect.

Also, the <Files> part is ONLY needed if you're executing "php." It has no effect on "php.pcgi."

In reply to:

In case you want to know how I do it, is simple. I simply delete the domain in DH Control Panel and wait 12 hours, to make sure the DH Bot kills everything. Then I add it again the same domain.


That's not something somebody can to on currently active sites. ^_^

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-01 12:52:00

Is faster then I thought... 1-2 hours.
It worked on 25min for one site.. I will post official results, once I do more tests. I have plenty of domains to add.
In this way, you guys can switch also your sites to Apache 2.0.

About the htaccess config, this is what I use, related to Files:

<Files php>
SetEnv PHP_FCGI_MAX_REQUESTS 5000
SetHandler fastcgi-script
</Files>

Should I leave the PHP_FCGI_MAX_REQUESTS setting?
The other setting is useless, since you run no child proceses...

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-07-01 13:00:00

In reply to:

About the htaccess config, this is what I use, related to Files:

<Files php>
SetEnv PHP_FCGI_MAX_REQUESTS 5000
SetHandler fastcgi-script
</Files>

Should I leave the PHP_FCGI_MAX_REQUESTS setting?


<Files> is an Apache directive that says "files matching this pattern." You have to use regex for patter matching, so what you're saying is this: "file that is named 'php'"

Then it applies those directive only to that one file.

Since your file is called php.fcgi, it does not effect your excutable at all. It's a wasted delcaration. ^_^

Remember, I did <Files "php"> because I did NOT want to rename "php" to "php.fcgi." I specifically left it "php" to insure each updates for when I update PHP on my end.
(make install and boom, php binary updated on the command line and website in one step).

I also got rid of the <Files> declaration by just adding a .htaccess file to my bin directory with SetHandler fastcgi-script, and any other directives relevant.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-01 13:04:00

Aha, you mean in the directory /local/bin where you find the execs: curl php phpize etc?
What's the content of your .htaccess there? Thanks.

Also, I was reading on Google that is not recommended to do a symlink to php, but instead to actually copy php (renamed to php.fcgi) to /cgi-bin
Give me more details how you did it yourself, step by step.

Thanks.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-07-01 13:44:00

In reply to:

Also, I was reading on Google that is not recommended to do a symlink to php, but instead to actually copy php (renamed to php.fcgi) to /cgi-bin
Give me more details how you did it yourself, step by step.


/nod, that's because simlinking it gives peple direct access to all the other files within that directory through the browser. ^_^

One of these days, I'll lock down the directory itself, too. But for now, I'm going the lazy route. lol

The above is what I have, that's it. As I stated earlier, I tested out the SetEnv options, and they did not work.

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-07-01 14:23:00

That was taken from the daily CPU usage log, found in the /home/dhuser/logs/domain.com/resources folder. (You have to enable it to show up from the DH control panel.)

That was not a real-time snap shot.

A realtime snap shot, using the "Top" command, (while I click on various links on my forum) ... www.pennyquick.com/top.jpg

And, from status.php ...

Operating System: Debian 3.1
Processor: Dual Core AMD Opteron(tm) Processor 175 (2194.542MHz)
Load averages: 1.55, 1.57, 1.72
Current processes: 8 (7 sleeping, 1 running, 0 zombie)
Processes by CPU: (other) (7) 0.3%
Memory usage: 96.749% (3942604k / 4075076k)
Swap: 3.648% (230316k / 6313512k)

...

P.S. : Did you compile your PHP with the --enable-inline-optimization switch ? I just re-compiled mine... I think I've lowered the number of database queries... but then again, it could all be psychological.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-07-01 16:03:00

I hadn't seen inline-optimization option. I couldn't find any details on what that is online. There is this within the configure --help

In reply to:

--disable-inline-optimization
If building zend_execute.lo fails, try this switch


Sounds to me it's already enabled by default.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-01 17:21:00

No, I did not.
--enable-inline-optimization is recommended by the PHP team if you have "lots of memory". Since we don't have our own server, it's not recommended in our case.
PHP disables inline optimizations by default, due to the GCC compiler failing when the target is one of the new 64 bit processors.

Ok some updates related to my Apache 2.0 switch.
The good part is that you don't need to use anymore the SetHandler fastcgi-script directive, it's set by default in their https.conf file. That is hapening because I copy the /bin/php file to /cgi-bin/php.fcgi. Because it's seen with the extension .fcgi, everything runs automatically as fastCGI.
Good! smile

Related to the method that guice used, I don't like the fact that everyone could have access to my vital directory. So I will stick with my method, copying the the php file to /cgi-bin/php.fcgi, chmod the /cgi-bin dir to 751 to allow only execution for guests, then do a symlink to /cgi-bin for each domain I have.

It looks like it takes in average 1 hour, until the DH Bot kills all information related to your current domain settings. After 1 hour of waiting, you simply add again your domain through the DH Control Panel and... bingo, you are on Apache 2.0 smile

Look:
http://www.adolympics.com/apc.php

Apache/2.0.54 (Unix) PHP/4.4.2 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.1.4

Smooth!

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-07-02 09:47:00

Fellas,

I have comment / question. I know that APC stores PHP files in the compiled state. Now, is it possible, for APC to store other file types in its cache -- say like .css, .html, or even .gif or .jpg ?

Don't laugh.

I was thinking ... in the .htaccess file, if you added something like (And I don't know if this is even right) :

AddType application/x-httpd-php .php .html .css
AddHandler fastcgi-file .php .html .css
Action fastcgi-file /cgi-bin/php.fcgi

then you'd start to see .css and .html files in the files cached on apc. Moreover, wouldn't you get some kind of performance boost though zlib if the file being outputted is a .php file ?

Doing this :

AddHandler application/x-httpd-php .php .html
AddHandler application/x-httpd-html .css

Seems to speed things up a bit.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-02 10:47:00

All the image extensions, javascript and .css files are stored locally into your browser cache, it's a waste of memory to use APC for that. smile
Mainly, the APC cache works by storing the compiled instructions for a PHP script in shared memory. When a file is run, APC checks to see if it is cached. If so, the instructions are read from memory and the compilation step is bypassed. Otherwise the file is compiled as usual and inserted into the cache.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-02 11:00:00

EDIT: Hmm, someone deleted your post nite?
I will answer anyway...
First, I don't know how to enable the system resources. There are a lot of things I did not have time to look in the DH Control Panel.
Let me know how to do it, I will post the results.

About the difference, this really depends on the size and complexity of your PHP code. A 50% performance improvement is typical for a "Hello World" program, but the potential benefit is greater as the code increases in complexity, for example the vBulletin forum software. You can get a roughly 400% performance improvement in a production environment. As always, your mileage may vary.

vBulletin forums have a specific class designed to use APC, in order to improve the overall performance.
I've been a solid vBulletin user/coder since 2001 and I can confirm that they have one of the best structure and code optimization, for a forum software.

Edited by TECK on 07/02/06 11:01 AM (server time).

Re: APC installed on Dreamhost? It was done...

Posted by: nite
Posted on: 2006-07-10 19:27:00

According to this post, http://litespeedtech.com/community/forum/showthread.php?t=450 , there's a problem with php v5.1.4 and fastcgi ...

I'm going back to 4.4.2 ... enough experimenting.

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-07-10 19:38:00

It mentioned about dealing with PHP_FCGI_CHILDREN, which is where I saw the problem. Which is also why I recommended not using it.

Everything's running fine with just the single process.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-14 02:35:00

Yep guice, everything is running smooth for me also, with one single process (the way you mention it). No hickups at all.
Nite, why you want to go back to 4.4.2? I will stick with 5.1.4, it's running perfectly. I don't like to go back to Ice Age (I like that movie). smile

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-07-17 22:57:00

I wonder if I should recompile APC with option:
--with-apxs=/usr/local/dh/apache2/template/sbin/apxs

guice, let me know...

Re: APC installed on Dreamhost? It was done...

Posted by: guice
Posted on: 2006-07-21 14:28:00

Sorry for the late reply. This forum has always been down every time I tried to used it.

No, don't use apxs. That's for Apache shared modules. You're not installing it into Apache.

Re: APC installed on Dreamhost? It was done...

Posted by: TECK
Posted on: 2006-08-06 12:50:00

I managed to install also memcache, so far running smooth.
However, there are few php.fcgi instances running, instead of one, like it used to be before?

Wierd.
Anyway, let's get on with the install.
I will post only the key install steps, that gave me errors.

${PHP_DIR} - /home/username/local or whatever you name it in the install script

In php.ini, change the memory limit to 32MB:
memory_limit = 32M

In .bashrc add:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HOME}/local/lib

When you compile PHP, you need to add:
--enable-memory-limit
--enable-memcache
--enable-sockets

MEMCACHE Install
sh ./configure --prefix=${PHP_DIR}

Make sure you have libevent installed... then use this config:
# MEMCACHE Daemon Install
sh ./configure --prefix=${PHP_DIR} --with-libevent=${PHP_DIR}

Start your daemon:
memcached -d -m 64 -l 127.0.0.1 -p 11211 -u username

For the IP address, just ping your shell server, aka baa.dreamhost.com

Now, what will happen if the DH guys restart the Apache 2.0 server?
My memcached daemon will be killed. How do I restart it automatically?
DO you have a line that I could put in the .bash_profile or .bashrc?

Thanks.

Re: APC installed on Dreamhost? It was done...

Posted by: giorgio79
Posted on: 2006-09-15 01:52:00

Hi TECK,

nice posts in this topic!

I have read up on memcache at http://www.i-marco.nl/weblog/pivot/entry.php?id=209,

and it seemed to me that I would need to modify the app itself, not just the php environment. From your post it seems like I just need to install it and some kind of caching will occur?

Also, I managed to install eAccelerator, but it shows only one cached script (the control file itself) I tried surfing simple pure html pages as well, but they were not cached. Would you or anyone else have ideas on what could be wrong?

And at last, in dreamhost wiki, there is a section on php.ini which explains how to install your custom php.ini, would not this be enough for an eaccelerator install? I need to compile an entire php?

Thanks,
Gyuri


Re: APC installed on Dreamhost? It was done...

Posted by: giorgio79
Posted on: 2006-09-15 04:14:00

Ah, nevermind, I got it working! eAccelerator is caching tons of my scripts!!!! jeeeeee

My problem was addressed earlier on in the post, just rename php5.cgi to php5.fcgi and change it in htaccess. Now control.php shows tons of cached scripts. I think it was caching since I installed it, but because I did not rename cgi, it did not show the cached scripts... What a relief. After 1 week of messing around with accelerators.

As of APC it is not working for me. It is giving me internal server errors unfortunately. Anybody experienced the same?

Gyuri

Re: APC installed on Dreamhost? It was done...

Posted by: ilikenwf
Posted on: 2007-06-05 17:45:00

I compiled php5, but the script I found that actually worked ended up not compiling it with fastcgi. Does that mean I need to delete everything and start over to get APC? I tried compiling, after getting all requirements taken care of, and it finally did compile, but it isn't loading, even though I have added it to my php.ini file, and have edited .htaccess, with the exception of adding fcgi...

I used this script: http://michaelraichelson.com/plex/2005/02/25/php5-for-dreamhost-install-script/ , coupled with the install instructions here, on the APC install guide (that vBulletin post), and from http://blog.robinz.info/archives/2006/02/15/how-to-install-eacceleartor-on-dreamhosts-host/ (just used it to remember to use export..., no I don't want eAccelerator, but the installations are similar from what I gather...)




Edited by ilikenwf on 06/05/07 05:49 PM (server time).

Tags: apcdreamhostphp extensionsphp versionphpinfohttpwgetlocalapache moduletgzlibpecl