PHP configuration/fr

PHP est un système de pages web qui s'est développé accidentellement au sein d'un langage général assez raisonnable. La syntaxe de PHP, ses fonctionnalités et son modèle d'exécution présentent de vagues similitudes avec Perl ; les scripts sont chargés par un interpréteur, compilés en bytecode puis exécutés. L'interpréteur PHP peut être lancé en ligne de commande, au format CGI ou plus communément comme un module intégré de Apache.

Compatibilité MediaWiki
Voir les versions de PHP compatibles avec votre version de MediaWiki sur Compatibility#PHP

Installation
Veuillez voir https://secure.php.net/install.

Requis
Les extensions suivantes sont nécessaires à MediaWiki : MySQL et PostgreSQL via PDO ne sont pas compatibles
 * Perl Compatible Regular Expressions : gestion des expressions régulières via PERL
 * Session
 * Bibliothèque Standard de PHP
 * Document Object Module
 * iconv bibliothèque de conversion des jeux de caractères
 * JSON (ou encore le fork pecl-json-c)
 * mbstring gestion des chaines de caractères codés sur plusieurs octets
 * fileinfo détection du type MIME
 * Au moins un pilote de base de données :
 * MySQL
 * PostgreSQL
 * SQLite (via PDO)

Perl Compatible Regular Expressions, Session, Standard PHP Library et JSON sont activés par défaut ; Perl Compatible Regular Expressions et Standard PHP Library ne peuvent pas être désactivées à partir de la version 5.3 de PHP.

Facultatif
MediaWiki nécessite ou demande que certaines fonctionnalités facultatives de PHP soient activées à la compilation :
 * zlib bibliothèque de compression, utilisée également pour compresser les fichiers en cache
 * sockets support pour les communications en réseau, en cas d'utilisation de memcached
 * FastStringSearch (recherche rapide de chaine)

Exemple
Nous travaillons avec succès avec ces options de compilation :

 './configure' \ '--with-mysql' \ '--with-apxs2=/usr/sbin/apxs2' \ '--with-zlib' \ '--with-ldap' \ '--with-gd' \ '--with-jpeg-dir' \ '--with-iconv-dir' \ '--enable-mbstring' De manière détaillée, ces options de configuration procèdent comme suit :


 * --with-mysql : Allows PHP to query MySQL. This is an essential feature (I think). You will need to have MySQL installed to enable this option.
 * --with-apxs2=/usr/sbin/apxs2 : this is required if you want to build mod_php. APXS is for configuring compilation of an Apache module. You will need to change (or omit the path) for your specific system.
 * --with-zlib : Allows PHP to read / write zipped files and send compressed data to Apache ... or something like that
 * --with-ldap : Important if you want your wiki users to be verified by LDAP
 * --with-gd : Use this if you want image processing 'within' PHP, else you can use ImageMagick. Because this option requires that you have various libraries installed... but presumably IM has the same deps... oh well...
 * --with-jpeg-dir : Seems nonsensical
 * --with-iconv-dir : Seems nonsensical
 * --enable-mbstring : Allows multibyte character string support. This is optional, as slower custom code will be used if not available.

Opcode caching

 * See

Due to MediaWiki's large codebase, it is highly recommended that a system be used to cache the compiled scripts; there are a number of such plugins for PHP, some free, some proprietary. There is a list of some caches:
 * Alternative PHP Cache -- used at Wikimedia
 * Windows Cache Extension for PHP -- recommended for IIS users

Fortunately, these all seem to be easy to install as Zend plugins, you just drop in a library and change your php.ini. No fussy recompiling of the entire PHP!

Depending on the cache and options used, you may have to perform a special operation whenever updating script files.

MediaWiki can also interact with that caches and use them for object caching, see.

Runtime configuration (php.ini)
Some settings in php.ini affects MediaWiki behavior and some of them are incompatible with MediaWiki


 * register_globals


 * safe_mode
 * Safe mode is an ill-conceived, broken-by-design setting in PHP; MediaWiki can work with this option on, but some features won't work.


 * magic_quotes_gpc
 * This options adds quotes to data in,   and  . MediaWiki can work with this option turned on, but will have to remove these quotes and thus will be slower.


 * magic_quotes_runtime
 * This option corrupts data input unpredictably by adding quotes in e.g. opened files, data received from database etc. MediaWiki will refuse to install if this option is turned on.


 * magic_quotes_sybase
 * same as magic_quotes_runtime


 * mbstring.func_overload
 * This option causes errors and may corrupt data unpredictably; MediaWiki will refuse to install if this option is turned on.


 * zend.ze1_compatibility_mode
 * This option causes horrible bugs; MediaWiki will refuse to install if this option is turned on.


 * memory_limit
 * MediaWiki needs sufficiently memory to work. The minimal limit should be something like 20 MB, but if you want MediaWiki to work correctly, consider using at least 50 MB.


 * disable_functions
 * To be able to find GNU diff3 and git during installation process this entry must not contain passthru


 * post_max_size
 * If you are getting the error " " then it could be because this is set with a "MB" prefix, instead of just "M" (the former is interpreted at bytes, not megabytes).

Image Resizing
ImageMagick can be used for image resizing. When it is not available, the GD PHP module is used instead where found.

Voir aussi

 * PHP Knowledgebase
 * PHP Tutorials
 * Suhosin (Hardened-PHP Project patch and extension)