php Accelerator (APC) help needed

php Accelerator (APC) help needed

by Henry Johnson -
Number of replies: 11
Hi,

I'm new to running Moodle and we have just set up our school server running Ubuntu Linux 6.06 LTS with the 2.6.15-26-686 symmetrical multi-processor preemptive kernel. Moodle version is 1.6.1, running on Apache 2.0.55 with PHP 5.1.2 and MySQL 5.0.22

As it is getting an exponential increase in usage, I thought it would be a good idea to install the apc php accelerator. I used this installation guide:

http://baheyeldin.com/technology/linux/installing-php-apc-on-ubuntu-dapper-and-debian.html

When I enable the accelerator (extension=apc.so in php.ini) I get these errors at the top of the moodle pages as well as other stuff being broken, like not being able to load php.info


Warning: filename: typo3/class.t3lib_cs.php,
exec_fname: /usr/share/moodle/lib/textlib.class.php,
filepath: /usr/share/moodle/lib/typo3/class.t3lib_cs.php
in /usr/share/moodle/lib/textlib.class.php on line 28

Warning: filename: typo3/class.t3lib_div.php,
exec_fname: /usr/share/moodle/lib/textlib.class.php,
filepath: /usr/share/moodle/lib/typo3/class.t3lib_div.php
in /usr/share/moodle/lib/textlib.class.php on line 29

Warning: Cannot modify header information - headers already sent by
(output started at /usr/share/moodle/lib/textlib.class.php:28)
in /usr/share/moodle/lib/setup.php on line 431

It maybe a bug in apc-3.0.11, but it maybe the moodle php code doesn't like apc.  Line 431 in setup.php has to do with cookies, and the other lines are "require once".

Thanks for any help
Henry

Average of ratings: -
In reply to Henry Johnson

Re: php Accelerator (APC) help needed

by Bill White -
Hi Henry,

This not the answer, I am having the same problem as you are except that I have only 2 errors on my pages:

Warning: filename: typo3/class.t3lib_cs.php, exec_fname: /var/www/moodle/lib/textlib.class.php, filepath: /var/www/moodle/lib/typo3/class.t3lib_cs.php in /var/www/moodle/lib/textlib.class.php on line 28

Warning: filename: typo3/class.t3lib_div.php, exec_fname: /var/www/moodle/lib/textlib.class.php, filepath: /var/www/moodle/lib/typo3/class.t3lib_div.php in /var/www/moodle/lib/textlib.class.php on line 29

Also, I can no longer login to my site. I login but I just go bact to the front page and it says "You are not logged in"

Anyone out there that can help?

Cheers,
Bill
In reply to Bill White

Re: php Accelerator (APC) help needed

by Henry Johnson -
Hi Bill,

I am running Ubuntu linux, and the path for the php.ini is:

/etc/php5/apache2/php.ini

I made a couple of copies, e.g., php.old, php.apc and edited those. I copy the changed one across to php.ini, (saving the original first of course!) restart apache (apache2ctl restart, or /etc/init.d/apache2 restart) and see what happens.

When the site breaks, I copy back the old php.ini and restart and everything is back to normal (usually!).

So I'd just remove the "extension=apc.so" line from your php.ini file and restart apache. Err. I did read somewhere that bogus trailing spaces in your php files can cause these sort of errors too. Did you do any editing of the moodle php files?

I've got a couple of versions of php.ini now, as I tried compiling from source and doing some custom mods, but nothing works. I've sort of given up and will wait for the next release of apc, as this seems to be bug in the present release. We are lucky that we don't have a performance issue, so the matter is not that urgent.

This assumes you have root level access to the server on a console/terminal (I use ssh -X to tunnel an X session to either my Mac or Linix laptop).

Cheers
Henry
In reply to Henry Johnson

Re: php Accelerator (APC) help needed

by Bill White -
Hi Henry,

Thanks for your reply.

I am also using Ubuntu big grinon an old eMachine 500mhz/80gb/512mb, but as this is my testing server and I have all the rights and access I don't mind crashing it once in awhile.clown

Yeah, made a backup of my php.ini file and then edited it. Searched and tried all the possible but to no avail. So copied my backup and now everything is running fine except I don't have APC.sad

I decided not to touch any of the Moodle files as I felt it would most likely break something else, and then I would edit those files and then, well you know. I made this mistake before and then learned to just sit tight and wait for those who have the knowledge to come up with a fix.

I don't have any performance issues either, but I do like to dabble now and again, and thought it might be a good idea to gain the knowhow.

Will wait and see if anyone out there can help us.

Thanks for the info.

Cheers,
Bill
In reply to Bill White

Re: php Accelerator (APC) help needed

by Thomas Robb -
The symptoms that you describe about your moodle site saying that "you are not logged in" when you have, indeed, just logged in looks like a cookie problem to me.

Do you have two Moodles on the same machine?  If so, each of these moodles needs a unique prefix for the session cookie.  You can find the setting in the admin/configuration/variables.

Does that help?
In reply to Thomas Robb

Re: php Accelerator (APC) help needed

by Bill White -
Hi Thomas,

You would think it was a cookie problem, but it wasn't. I thought that at first but it wasn't on my browser. Now maybe when installing APC it broke the cookies being sent but after removing the extension=apc.so from my php.ini everything worked fine. See Myles comment below.

Cheers,
Bill
In reply to Henry Johnson

Re: php Accelerator (APC) help needed

by Myles Carrick -
Hey guys,
I just used pecl to update my apc and... voila.. got the same problem

this bug report (http://pecl.php.net/bugs/bug.php?id=8314&edit=1)seems to suggest that you're right in your diagnosis - it's an apc-3.0.11 error - sloppy coding!!!!! - it's debugging junk that wasn't commented out again in the apc codebase...

Let's hope an update is quickly forthcoming...

MC


In reply to Myles Carrick

Re: php Accelerator (APC) help needed

by Myles Carrick -
further to that... you can of course go back to the previous version...

uninstall the current version

pecl uninstall apc

then force it to use 3.0.10

pecl install apc-3.1.10

reload the webserver and you're cookin with gas!

MC
In reply to Myles Carrick

Re: php Accelerator (APC) help needed

by Bill White -
Hi Myles,

I can use a previous version of APC and I won't have the errors from before, very interesting. But, is it worth it to install a previous version or should I just wait for an update? Like I said I don't really need it, I just wanted to gain some experience installing and tweaking one for future reference.

I think I will try your suggestion though.

Cheers,
Bill
In reply to Bill White

Re: php Accelerator (APC) help needed

by Myles Carrick -
hi Bill,
You should be good to go with the previous version.
It's always good to just check out the changelog (http://pecl.php.net/package-changelog.php?package=APC&release=3.0.11) with packages like this to see if the reasons for upgrade were critical security things... in this case it doesn't look like it - and to be honest with an accelerator it shouldn't be!
Cheers,
Myles
In reply to Myles Carrick

Re: php Accelerator (APC) help needed

by Henry Johnson -
Yo Miles!

Right on the money! Except for the typo, it should be:

pecl install apc-3.0.10

I'm new to pecl and it works almost as good as apt-get and synaptic. I now have an APC section in my phpinfo page. Will upgrade when they release the bug fix.

I guess the next stage is to look deep into the mystery of tuning a php cache. I think I'll stick with APC rather than turck just 'coz it feels "newer".

Thanks
Henry
In reply to Henry Johnson

Re: php Accelerator (APC) help needed

by Bill White -
Hi Henry,

Just a quick note. If you want, you can install Turck on Ubuntu. You can install it with apt-get. Just finished and I will admit my speeds did increase, albiet not much but still noticable.

Cheers,
Bill