PHP configuration/pt-br

PHP is a web template system that accidentally grew up into a fairly general language. PHP's syntax, capabilities, and execution model bear vague similarities to Perl; scripts are loaded by an "interpreter", compiled to bytecode, and then executed. The PHP interpreter can be run from the command line, CGI-style, or more commonly as an in-process Apache module.

Compatibilidade do MediaWiki
For the allowed set of PHP versions you can use with your version of MediaWiki, see Compatibility#PHP.

Instalação
Por favor, consulte https://secure.php.net/install.

Requerido
The following extensions are required by MediaWiki: MySQL and PostgreSQL through PDO are not supported
 * Perl Compatible Regular Expressions
 * Session
 * Standard PHP Library
 * Document Object Module
 * iconv character set conversion library
 * JSON (alternatively, the pecl-json-c fork)
 * mbstring multibyte character string support
 * fileinfo MIME type detection
 * At least one database driver:
 * MySQL
 * PostgreSQL
 * SQLite (through PDO)

Perl Compatible Regular Expressions, Session, Standard PHP Library, and JSON are enabled by default; Perl Compatible Regular Expressions and Standard PHP Library cannot be disabled since PHP 5.3.

Opcional
MediaWiki either needs or wants a number of optional features of PHP that need to be enabled at compile time:
 * zlib compression library, optionally to compress the file cache
 * sockets support for network communication, if using memcached
 * FastStringSearch

Exemplo
We are successfully working with these compiler options:

 './configure' \ '--with-mysql' \ '--with-apxs2=/usr/sbin/apxs2' \ '--with-zlib' \ '--with-ldap' \ '--with-gd' \ '--with-jpeg-dir' \ '--with-iconv-dir' \ '--enable-mbstring' In detail, these configure options do the following:


 * --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.

Armazenamento em cache do opcode

 * 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.

Configurações em tempo de execução (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
 * Esta opção corrompe a entrada de dados imprevisivelmente, adicionando citações em, e. arquivos abertos, dados recebidos do banco de dados etc. O MediaWiki se recusará a instalar se esta opção estiver ativada.


 * magic_quotes_sybase
 * igual a magic_quotes_runtime


 * mbstring.func_overload
 * Esta opção causa erros e pode corromper dados imprevisíveis; O MediaWiki se recusará a instalar se esta opção estiver ativada.


 * zend.ze1_compatibility_mode
 * Esta opção causa erros horríveis; O MediaWiki se recusará a instalar se esta opção estiver ativada.


 * memory_limit
 * O MediaWiki precisa de memória suficiente para funcionar. O limite mínimo deve ser algo como 20 MB, mas se você quiser que o MediaWiki funcione corretamente, considere usar pelo menos 50 MB.


 * disable_functions
 * Para poder encontrar o GNU diff3 e git durante o processo de instalação, esta entrada não deve conter 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).

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

Ver também

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