Note: You are currently viewing documentation for Moodle 3.9. Up-to-date documentation for the latest stable version of Moodle may be available here: Installing APC in Windows.

Installing APC in Windows: Difference between revisions

From MoodleDocs
mNo edit summary
Line 50: Line 50:
* The apc.stat (file stating) which should be set to 1 otherwise you may get blank pages.
* The apc.stat (file stating) which should be set to 1 otherwise you may get blank pages.


A working PHP.INI settings are shown below, so copy and paste the following at the end of your PHP.INI file:
A working APC section of of PHP.INI is shown below, so copy and paste the following at the end of your PHP.INI file:


  [APC]
  [APC]

Revision as of 22:17, 24 December 2006

Introduction

APC (Alternative PHP Cache) is a PHP opcode cache. It stores PHP pages in RAM and reduces hard disk activity. This makes a real difference to the performance in Moodle, and you should be able to achieve a 50% increase in system capacity.

This guide is for installation of APC on a Windows server. The instructions have been tested on a Windows 2003 server, and they should also be applicable if you are using Windows XP as a test server.

Installation on Windows Server

Follow these steps to install APC.

Download the correct version

Download the windows binary for the PHP version you have installed from http://pecl4win.php.net/ext.php/php_apc.dll. Save into the PHP extensions folder, which is c:\php\ext by default.

Note: Make sure you choose the right extension for your version (branch) of PHP.

Enable the APC extension in your PHP.INI file

Edit the php.ini file and add the following line in the extensions section:

extension = php_apc.dll

Check that this has worked by restarting your web server and looking at the output of phpinfo from the Moodle administration screens (or from a text file containing this line:

<?php phpinfo(); ?>

Change APC settings for Moodle

The default APC settings are as follows:

apc.cache_by_default = On
apc.enable_cli = Off
apc.enabled = On
apc.file_update_protection = 2
apc.filters = 
apc.gc_ttl = 3600
apc.include_once_override = Off
apc.max_file_size = 1M
apc.num_files_hint = 1000
apc.optimization = Off
apc.report_autofilter = Off
apc.shm_segments = 1
apc.shm_size = 30
apc.slam_defense = 0
apc.stat = On
apc.ttl = 0
apc.user_entries_hint = 100
apc.user_ttl = 0
apc.write_lock = On

For a full explanation of these settings, see http://www.php.net/apc.

For a general Moodle installation several changes are needed. These are:

  • The apc.shm.size (the size of the cache) which should be set to at least 48Mb.
  • The apc.stat (file stating) which should be set to 1 otherwise you may get blank pages.

A working APC section of of PHP.INI is shown below, so copy and paste the following at the end of your PHP.INI file:

[APC]
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 48
apc.optimization = Off
apc.num_files_hint = 1000
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = On
apc.slam_defense = 0
apc.file_update_protection = 2
apc.enable_cli = Off
apc.stat=1

The remainder of the settings can be left as their default.

Set the temp directory

APC needs a temporary directory to save its files. It will attempt to save the files in the windows temp directory, so set the C:\WINDOWS\TEMP directory to be writable by the web server user (IUSR_machine-name), e.g. at least Read & Execute permissions.