PHP Integration · 2 min read · Oct 24, 2025
Intégration d'APC (Alternative PHP Cache) dans PHP5 (Debian Etch & Apache2)
Intégration d’APC (Alternative PHP Cache) dans PHP5 (Debian Etch & Apache2)
Version 1.0
Auteur : Falko Timme
Ce guide explique comment intégrer APC (Alternative PHP Cache) dans PHP5 sur un système Debian Etch (avec Apache2). APC est un cache d’opcodes PHP gratuit et open source pour mettre en cache et optimiser le code intermédiaire PHP. ** C’est similaire à d’autres caches d’opcodes PHP, tels que eAccelerator et XCache.
Je ne donne aucune garantie que cela fonctionnera pour vous !
1 Remarque Préliminaire
J’ai testé cela sur un serveur Debian Etch avec l’adresse IP 192.168.0.100 où Apache2 et PHP5 sont déjà installés et fonctionnent. J’utiliserai le répertoire racine par défaut d’Apache /var/www dans ce tutoriel à des fins de démonstration. Bien sûr, vous pouvez utiliser n’importe quel autre vhost également, mais vous devrez peut-être ajuster le chemin vers le fichier info.php que j’utilise dans ce tutoriel.
2 Vérification de l’État Actuel de PHP5
Tout d’abord, avant d’installer APC, découvrons notre installation de PHP5. Pour ce faire, nous créons le fichier info.php dans notre répertoire racine /var/www :
vi /var/www/info.php| |
Ensuite, nous appelons ce fichier dans un navigateur : http://192.168.0.100/info.php
Comme vous le voyez, nous avons PHP 5.2.0 installé…

… mais APC n’est mentionné nulle part sur la page :

3 Installation d’APC
APC est une extension PHP qui peut être installée à l’aide de PECL. PECL est fourni avec le package php-pear, donc nous l’installons maintenant :
apt-get install php-pearDe plus, nous devons installer certaines dépendances d’APC afin que PECL puisse construire APC :
apt-get install php5-dev apache2-prefork-dev build-essentialMaintenant que toutes les dépendances sont installées, nous pouvons installer APC comme suit :
pecl install apcserver2:~# pecl install apc
downloading APC-3.0.17.tgz …
Starting to download APC-3.0.17.tgz (116,058 bytes)
…………………….done: 116,058 bytes
47 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Use apxs to set compile flags (if using APC with Apache)? [yes] : <– ENTER
[…]
———————————————————————-
Libraries have been installed in:
/var/tmp/pear-build-root/APC-3.0.17/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the -LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to theLD_LIBRARY_PATH’ environment variable
during execution
- add LIBDIR to the LD_RUN_PATH' environment variable during linking - use the-Wl,–rpath -Wl,LIBDIR’ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf’
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).
running: make INSTALL_ROOT=”/var/tmp/pear-build-root/install-APC-3.0.17” install
Installing shared extensions: /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5/20060613+lfs/
running: find ”/var/tmp/pear-build-root/install-APC-3.0.17” -ls
998152 4 drwxr-xr-x 3 root root 4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17
998214 4 drwxr-xr-x 3 root root 4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr
998215 4 drwxr-xr-x 3 root root 4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib
998216 4 drwxr-xr-x 3 root root 4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5
998217 4 drwxr-xr-x 2 root root 4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5/20060613+lfs
998213 416 -rwxr-xr-x 1 root root 418822 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5/20060613+lfs/apc.so
Build process completed successfully
Installing ’/var/tmp/pear-build-root/install-APC-3.0.17//usr/lib/php5/20060613+lfs/apc.so’
install ok: channel://pecl.php.net/APC-3.0.17
Vous devez ajouter ”extension=apc.so” à php.ini
server2:~# Maintenant qu’APC est installé, nous créons le fichier de configuration /etc/php5/conf.d/apc.ini. Nous devons au moins ajouter la ligne extension=apc.so là-dedans ; toutes les autres options de configuration sont facultatives. Vous pouvez trouver une liste de toutes les options de configuration disponibles sur http://de2.php.net/manual/en/ref.apc.php. vi /etc/php5/conf.d/apc.ini | extension=apc.so apc.enabled=1 apc.shm_size=30 | C’est tout. Redémarrez Apache, et vous avez terminé : /etc/init.d/apache2 restart Ensuite, ouvrez à nouveau info.php dans un navigateur : http://192.168.0.100/info.php Vous devriez maintenant voir APC mentionné sur la page, ce qui signifie qu’il a été intégré avec succès et fonctionne comme prévu :
### 4 Liens - APC : http://pecl.php.net/package/APC - PHP : http://www.php.net - Apache : http://httpd.apache.org - Debian : http://www.debian.org
Recevez de nouveaux articles dans votre boîte de réception.
Aucun spam. Désabonnez-vous à tout moment.