PHP configuration/ru
From MediaWiki.org
PHP - это система сетевых шаблонов, которая выросла в общем-то полноценный язык программирования. Синтаксис, возможности и модель выполнения PHP имеет общие черты с Perl; скрипты загружаются "интерпретатором", компилируются в байткод и затем выполняются. Интерпретатор PHP может быть запущен из командной строки, как модуль CGI, но как правило используется внутри-процессный модуль Apache.
Contents |
[edit] Пример
$url = $_GET['module']; switch ($url) { case 'module1': echo "module = module1"; break; case 'module2': echo "module = module2"; break; case 'module2': echo "module = module2"; break; default: echo "module not found!"; break; }
[edit] Установка
Пожалуйста, посмотрите http://www.php.net/manual/en/installation.php.
[edit] Опции компиляции
[edit] Необходимое
Следующие расширения необходимы для MediaWiki:
- Perl Compatible Regular Expressions
- Session
- Standard PHP Library
- Хотя бы один драйвер СУБД:
- MySQL
- PostgreSQL
- SQLite (through PDO)
- MySQLi, MySQL и PostgreSQL через PDO не поддерживаются
Perl Compatible Regular Expressions, Session и Standard PHP Library подключены по умолчанию; Perl Compatible Regular Expressions и Standard PHP Library не могут быть отключены с версии PHP 5.3.
[edit] Дополнительное
This page is in progress of translating to Russian. You can help translating it or go to another language version that follows:
Эта страница в процессе перевода на русский язык. Вы можете помочь в переводе или перейти на другие языковые версии, указанные ниже:
Для MediaWiki необходимы или желательны некоторые опции PHP, подключение которых выполняется при компиляции :
- mbstring поддержка строк из многобайтовых символов (желательно; при недоступности будет использован более медленный собственный код)
- iconv библиотека конвертации штрифтов (желательно; при недоступности будут использованы другие функции конвертации)
- zlib библиотека сжатия, желательна для сжатия файлового кеша
- sockets support for network communication, if using memcached
- dba DBM-style database abstraction layer, for caching, with the following handlers:
- CDB for interwiki cache (and maybe some other things)
- Berkely DB3 if you want to use CACHE_DBA in either $wgMainCacheType, $wgParserCacheType or $wgMessageCacheType
[edit] Example
We are successfully working with these compiler options:
'./configure' \ '--with-mysql' \ '--without-sqlite' \ '--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.
- --without-sqlite
- This simply trims down the build by removing an unnecessary component of PHP. This is not essential, but it should make the build less likely to fail due to missing dependencies and should result in a smaller PHP install.
- --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.
[edit] Opcode caching
If running a high-traffic site, 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:
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 Manual:$wgMainCacheType.
[edit] Runtime configuration (php.ini)
Some settings in php.ini affects MediaWiki behaviour and some of them are incompatible with MediaWiki
- register_globals
Warning: Enabling this is a major security risk and can be used for XSS attacks; MediaWiki doesn't require it, so please turn it off if you can!- 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
$_GET,$_POSTand$_COOKIES. 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 Mo, but if you want MediaWiki to work correctly, consider using at least 50 Mo.
[edit] Image Resizing
ImageMagick can be used for image resizing (see Manual:Configuration settings#Images). When it is not available the GD PHP module is used instead where found.