PHP Integration · 3 min read · Oct 24, 2025

Intégration d'APC (Alternative PHP Cache) dans PHP5 (Fedora 8 & Apache2)

Intégration d’APC (Alternative PHP Cache) dans PHP5 (Fedora 8 & Apache2)

Version 1.0
Auteur : Falko Timme

Ce guide explique comment intégrer APC (Alternative PHP Cache) dans PHP5 sur un système Fedora 8 (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 Fedora 8 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/html 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/html :

vi /var/www/html/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.4 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 en utilisant PECL. PECL est livré avec le package php-pear, donc nous l’installons maintenant :

yum install php-pear

De plus, nous devons installer certaines dépendances d’APC afin que PECL puisse construire APC :

yum install php-devel httpd-devel
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'

Maintenant que toutes les dépendances sont installées, nous pouvons installer APC comme suit :

pecl install apc

[root@server1 ~]# pecl install apc
downloading APC-3.0.18.tgz …
Starting to download APC-3.0.18.tgz (115,957 bytes)
…………………….done: 115,957 bytes
47 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

  1. Use apxs to set compile flags (if using APC with Apache)? : yes

1-1, ‘all’, ‘abort’, or Enter to continue: <– ENTER

[…]

———————————————————————-
Libraries have been installed in:
/var/tmp/pear-build-root/APC-3.0.18/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.
    Don’t forget to run ‘make test’.
    running: make INSTALL_ROOT=”/var/tmp/pear-build-root/install-APC-3.0.18” install
    Installing shared extensions: /var/tmp/pear-build-root/install-APC-3.0.18/usr/lib/php/modules/
    running: find “/var/tmp/pear-build-root/install-APC-3.0.18” -ls
    1996900 4 drwxr-xr-x 3 root root 4096 Apr 8 16:32 /var/tmp/pear-build-root/install-APC-3.0.18
    1996959 4 drwxr-xr-x 3 root root 4096 Apr 8 16:32 /var/tmp/pear-build-root/install-APC-3.0.18/usr
    1996960 4 drwxr-xr-x 3 root root 4096 Apr 8 16:32 /var/tmp/pear-build-root/install-APC-3.0.18/usr/lib
    1996961 4 drwxr-xr-x 3 root root 4096 Apr 8 16:32 /var/tmp/pear-build-root/install-APC-3.0.18/usr/lib/php
    1996962 4 drwxr-xr-x 2 root root 4096 Apr 8 16:32 /var/tmp/pear-build-root/install-APC-3.0.18/usr/lib/php/modules
    1996958 432 -rwxr-xr-x 1 root root 435950 Apr 8 16:32 /var/tmp/pear-build-root/install-APC-3.0.18/usr/lib/php/modules/apc.so
    Build process completed successfully
    Installing ‘/usr/lib/php/modules/apc.so’
    install ok: channel://pecl.php.net/APC-3.0.18
    configuration option “php_ini” is not set to php.ini location
    You should add “extension=apc.so” to php.ini
    [root@server1 ~]# Maintenant qu’APC est installé, nous créons le fichier de configuration /etc/php.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/php.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/httpd 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 - Fedora: http://fedoraproject.org
Share: X/Twitter LinkedIn

Recevez de nouveaux articles dans votre boîte de réception.

Aucun spam. Désabonnez-vous à tout moment.