I'm trying to install APC on our moodle site, running 2.5.1 because we've had some loading speed issues (even though we have very very few concurrent users). I have all of the APC files on the server, unzipped, but I can't figure out how to run APC. I don't have root permission, since it's a shared server, so permissions won't let me run ./apc.php or ./install.php. When I go to mysite.moodle.com/apc.php I get the message "No cache info available. APC does not appear to be running." I'm fairly new to all this, so any help would be greatly appreciated.
Issues installing APC on shared server
Number of replies: 8Re: Issues installing APC on shared server
From the perspective of a Linux CentOS server (Ubuntu probably similarr) ... the only way one can install APC is via pecl - it's an extension to PHP that has to be complied. The initialization file (start up) for it goes in /etc/php.d/ on a CentOS server. Talk to your provider about installing it.
Have to be honest about that last suggestion .... I doubt they will, as that affects every customer on a shared hosting server. However, it doesn't hurt to ask!
But, also check with them to see if they do provide an opcache for customers. You might need to move your package to a VPS where you could then have more control over such things.
Also, while APC does work and works well, Moodle currently supports only memcache, memcached, and MongoDB. **ALL three require installation of another server to use. :\ [so much for the little guy!]
Care to share provider?
'spirit of sharing', Ken
Re: Issues installing APC on shared server
You can run APC within Moodle - within 2.5 anyway - I have it running through the general caching setup. Once you have it installed and I do believe that you need to install the pecl package too, you need to go to plugins, caches and create an apc instance and then assign to it those parts of moodle that you want to use it as a cache.
Good info and directions here:
Re: Issues installing APC on shared server
That's true ... thanks for reminding ... forgot about it And let me repeat ... it won't install APC, but provide a Moodle interface into it's config.
Uhhh .... pardon for disagreeing a little, but maybe the reason I 'forgot' about is a matter of perspective. The plugin would allow one to be 'involved' in setting up APC as to what to cache, etc., but I got to thinking about the time spent doing that ... and maybe the knowledge required to 'get it right'. So, along those lines of thinking (being somewhat lazy and not wanting to spend yet *more* time on care and feeding) decided that allocating enough memory to APC to do it's thing was the easiest way to go.
The php files don't change ... unless updating a plugin or upgrading ... so why wouldn't I want APC to cache them all ... especially the larger and most hit ones ...
Example:
/var/www/html/moodle/lib/setup.php | 219191 |
184592 |
Tweaking the APC settings especially the apc.ttl (tme to live) one could eventually hit upon what is optimal for server usage. Actually, haven't had to tweak that much at all - even with an entity that is using Moodle in just about every usage mod/model ... F-2-F daily, blended, and flipped.
My 2 cents, of course.
'spirit of sharing', Ken
Re: Issues installing APC on shared server
Yes, sorry, I totally forgot to mention that I have a shared account with Dreamhost, which runs Debian. I've been following their instructions for installation here, but I've gotten a little stuck. When I run $php-5.4 -i | grep apc nothing happens. I followed their instructions here for working around the php.ini file by making a phprc file, which is where I think I must have gone wrong. The file has only the line "/home/YOURUSER/WHERE/APC/IS/apc.so" as they instruct (I removed the = because it was giving me an error).
Re: Issues installing APC on shared server
When you run the php -i|grep apc it shows it's not installed. Actually, in your case, just may not know where it's installed. That one line you found the directions couldn' t be specific so they used CAPS for the items you were to replace. /home stays, and you should know /youruser/ but WHERE/APC/IS kinda depends upon you.
As I read the directions: Step 6: Copy modules/apc.so from the APC directory somewhere else.
So lets see if this works ... make a directory called apc in /home/youruser/. Copy the modules/apc.so from the compiled APC directory to /home/youruser/apc/
The entry in that other thing is now:
/home/yourname/apc/apc.so
Step 7 and 8, however, talk about setting up a custom php.ini:
7. Setup a custom PHP.ini.
8. Add the line extension = /home/YOURUSER/WHERE/APC/IS/apc.so to the custom php.ini along with any other APC config lines you need.
Here's what I have in an apc.ini file on a server that host multple Moodles:
extension=apc.so
Your extension line will include the path:
extension=/home/yourname/apc/apc.so
apc.shm_size=800M
; will check a requested PHP file for modifications since the last time it was cached
apc.stat=1
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M
There are other lines one can find to add to it that deal with ttl (time to live) settings. Google for setting up APC and you'll see some other folks recommendations. When reading them, however, remember you are on a shared host and will be restricted ... OR, if going over limits, will DreamHost shutdown your server? or charge for overage?
Other php items are the ones related to max file size upload, max time to execute, max memory to use for script ... like so (again, dunno what your limits are ... might have to adjust):
; http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time
max_execution_time = 60
; http://www.php.net/manual/en/info.configuration.php#ini.max-input-time
max_input_time = 90
; http://www.php.net/manual/en/ini.core.php#ini.post-max-size
post_max_size = 400M
; http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
upload_max_filesize = 400M
'spirit of sharing', Ken
Re: Issues installing APC on shared server
Yes, I had replaced the caps with my own file path, so that it read /home/myusername/apc/apc.so. I've tried running it with the file in both the outer server directory, and in the subdomain directory (/home/myusername/subdomain/apc/apc.so) that we're running moodle on, but it didn't work either time.
I've done some googling, but I haven't been able to find any guides that deal with shared servers and how to work around the access to the php.ini file. I thought that phprc was meant to somehow override php.ini but maybe I'm misunderstanding it.
Thanks again for all your help.
Re: Issues installing APC on shared server
Depending on your hosting plan, some shared hosting providers do not allow the use of an in-memory opcode cache. So before you go any further on figuring it out make sure from your provider if you can use a in-memory cache like APC. From my experience they do not allow it on a shared server is because it runs in memory and is a security issue since any other user of that server would be able to obtain access to that in-memory cache.
If Ubuntu you can use sudo apt-get install php-apc, restart apache, done. If you use PECL than it would be the version that Canonical would not support.
JASON
Re: Issues installing APC on shared server
I'm using dreamhost, which does appear to allow APC use on shared serveres since they have a tutorial. However, part of their tutorial redirects you to a page (as I mention in my reply to Ken), where you seem to need root access. I'll try to look into it further - thank you!