Welcome Guest, Not a member yet? Register   Sign In
Codeigniter won't run with APC installed

I just installed memcache and APC on my localhost and once I ran one of my codeigniter application I got spammed with this message like 200 times over:

Quote:Notice: Constant CI_VERSION already defined in C:\wamp\www\g\mvc\codeigniter\CodeIgniter.php on line 31

I tried to comment out the line but now I have an even bigger problem, the entire server crashes and I get the following error message in my apache_error.log:

Quote:[apc-error] Cannot redeclare class ci_benchmark in C:\wamp\www\g\mvc\codeigniter\Common.php on line 127.

Is there something I have to do to get APC to work correctly?


I solved the problem by turning off apc.cache_by_default, shouldn't I be able to have this on?


Forget APC . Go with Xcache .
I recently used it on one of my servers and the result was unbelievable .
From 5 Mb/req i went down to 0,7-1,5mb on high load pages . The loading time decreased from 0,4XX-0,9XX to 0,077-0,1XX .

BTW, i don't believe that building an application from zero on top of APC / Xcache / Memcached is a good idea.
Your app must scale in normal conditions , and apply these changes ONLY when your server is a powerful one and can't handle all the requests any more .

I have had APC running on my development machine (MAMP and OS X) and on my production servers for over a year now. No problems whatsoever. This could be a windows thing I suppose. Perhaps see what other op caching extensions you have running?

As you can see, I have cache by default ON on my production server:

APC Support     enabled
Version     3.0.19
MMAP Support     Enabled
MMAP File Mask     /tmp/apc.TwYlFc
Locking type     pthread mutex Locks
Revision     $Revision: $
Build Date     Sep 21 2009 16:01:14

Directive    Local Value    Master Value
apc.cache_by_default    On    On

Weird that I get redeclare errors when your able to run it without any problems, do you run CI 1.7.2?


I always develop for scalability for a couple of reasons:
1. you get to learn impressive tweaks.
2. the application is fast and awesome. Smile
3. you doesn't have to think about implementing complex solutions last minute.

I also develop large applications at work so its a good if I know whats possible and not.

This makes perfect sense ONLY if you are planning to deploy your app on a dedicated/vps server , where you can control what's installed and what not .
If you are building apps for shared hosting , building them on top of caching mechanisms as APC or even memcached is still a bad idea, but as you mentioned it's not your case .

It seems you could also make a driver. vBulletin does this. You can have no cache, apc, memcached, etc. Then just select which one in the config and have nocache as default.

Try changing the $system variable in index.php from relative to absolute path.

Find index.php and change:
$system = '../system';
$system = '/var/www/system'; //change to whatever the full path to CI's system folder is on your server.

Theme © iAndrew 2016 - Forum software by © MyBB