Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Редактирование wp-config.php

ВНИМАНИЕ: Прочтите перед редактированием этой страницы.

Пожалуйста, не указывайте в данной статье параметры своего собственного сайта, поскольку при этом вы сообщите пароль от своей базы данных всему миру, но сайт не запустите. Спасибо.

Contents

Одним из шагов при установке WordPress является внесение в файл wp-config.php параметров, необходимых для доступа к базе данных MySQL.

Этот файл, wp-config.php, не содержится в скачиваемой копии WordPress; вам потребуется его создать. В качестве примера можно использовать файл wp-config-sample.php. Ниже представлены расширенные настройки и примеры.

Для изменения файла wp-config.php вам потребуется следующая информация:

Имя базы данных 
Имя базы данных для WordPress
Имя пользователя базы данных 
Имя пользователя для доступа к базе данных
Пароль к базе данных 
Пароль пользователя для доступа к базе данных
Сервер базы данных 
Имя сервера базы данных

Если WordPress установлен вашим хостинг-провайдером, узнайте эту информацию в службе поддержки. Если у вас свой собственный сервер или хостинг, вы получите эту информацию в результате создания базы данных и пользователя.


Настройка базы данных

Важно: никогда не используйте текстовые редакторы вроде Microsoft Word для изменения файлов WordPress!

Найдите в корневом каталоге WordPress файл wp-config-sample.php и откройте его в текстовом редакторе.

ЗАМЕЧАНИЕ: Начиная с версии 2.6, wp-config.php можно переместить в директорию на уровень выше той, в которой расположен WordPress.


Исходный wp-config-sample.php

Это пример исходного файла wp-config-sample.php. Значения приведены здесь в качестве примеров. Изменения нужно вносить не здесь, а на своём сайте. Если вы с помощью кнопки «Править» внесёте изменения здесь, они не подействуют, а вы сообщите свой пароль всему миру.


// ** Параметры MySQL: Эту информацию можно получить у вашего хостинг-провайдера ** //
/** Имя базы данных для WordPress */
define('DB_NAME', 'putyourdbnamehere');

/** Имя пользователя MySQL */
define('DB_USER', 'usernamehere');

/** Пароль к базе данных MySQL */
define('DB_PASSWORD', 'yourpasswordhere');

/** Имя сервера MySQL */
define('DB_HOST', 'localhost');

ЗАМЕЧАНИЕ: Текст внутри символов /* */ — это комментарии, приведённые в справочных целях.
ЗАМЕЧАНИЕ: Не меняйте значения на этой странице, меняйте их на своём сервере.


Укажите имя базы данных

Замените putyourdbnamehere на имя вашей базы данных, например МояБазаДанных.

define('DB_NAME', 'МояБазаДанных'); // Пример имени базы данных

Укажите имя пользователя базы данных

Замените usernamehere на имя вашего пользователя, например МоёИмяПользователя.

define('DB_USER', 'МоёИмяПользователя'); // Пример имени пользователя MySQL

Укажите пароль к базе данных

Замените yourpasswordhere на ваш пароль, например МойПароль.

define('DB_PASSWORD', 'МойПароль'); // Пример пароля к MySQL

Укажите сервер базы данных

Замените localhost на имя вашего сервера базы данных, например, МойСерверБазыДанных.

define('DB_HOST', 'МойСерверБазыДанных'); // Пример сервера базы данных MySQL


ЗАМЕЧАНИЕ: Скорее всего, последнее значение менять НЕ придётся. Если вы не уверены, попробуйте установить WordPress со стандартным значением 'localhost' в качестве имени сервера. Если установка завершится неудачей, обратитесь в службу поддержки вашего хостинг-провайдера.

Возможные значения DB_HOST

Различные хостинг-провайдеры используют различные сетевые настройки для серверов MySQL. Если ваш хостинг-провайдер указан в левом столбце, соответствующее значение DB_HOST справа должно подойти. Для уверенности обратитесь в службу поддержки и/или посмотрите онлайн-документацию вашего хостинг-провайдера.

Хостинг-провайдер Вероятное значение DB_HOST
1and1 db12345678
AN Hosting localhost
A Small Orange localhost
BlueHost localhost
DreamHost mysql.example.com
GoDaddy h41mysql52.secureserver.net
HostGator localhost
HostICan localhost
ICDSoft localhost:/tmp/mysql5.sock
LaughingSquid localhost
MediaTemple GridServer internal-db.s44441.gridserver.com
one.com localhost
pair Networks dbnnnx.pair.com
Rackspace Cloud mysql50-01.wc1.dfw1.stabletransit.com
Yahoo mysql
Сервера с cPanel localhost
Сервера с Plesk localhost
Сервера с DirectAdmin localhost
Tophost.it sql.your-domain-name.it
Sprinthost.ru localhost



Альтернативный порт MySQL

Если ваш хостинг-провайдер использует альтернативный порт для доступа к базе данных, нужно указать номер этого порта в параметре DB_HOST в файле wp-config.php.

Для localhost

 define('DB_HOST', 'localhost:3307');

Для другого сервера

define('DB_HOST', 'mysql.example.com:3307');

Замените 3307 на номер порта, полученный от хостинг-провайдера.

Кодировка базы данных

В WordPress версии 2.2 был введён параметр DB_CHARSET, чтобы иметь возможность указать кодировку базы данных (например, tis620 для тайской кодировки TIS620) при работе с таблицами MySQL.

Стандартное значение utf8 (Unicode UTF-8) почти всегда является наилучшим вариантом. UTF-8 поддерживает все языки, поэтому в общем случае в качестве DB_CHARSET стоит оставить utf8 и использовать значение DB_COLLATE для вашего языка.

Этот пример показывает UTF 8, которая считается значением WordPress по умолчанию:

define('DB_CHARSET', 'utf8');
ВНИМАНИЕ: Это применимо к новым инсталляциям

Там, как правило, не должно быть никаких причин для изменения значения DB_CHARSET по умолчанию. Если ваш блог нуждается в другом наборе символов, пожалуйста, прочитайте поддерживаемые наборы символов и сопоставлений MySQL для допустимых значений DB_CHARSET.

ВНИМАНИЕ: Это применимо к обновлениям (особенно блоги, которые существовали до версии 2.2)

Если DB_CHARSET и DB_COLLATE не присутствуют в вашем wp-config.php файле, НЕ добавляйте любого определения в ваш wp-config.php файл, если Вы не прочитали или не поняли Преобразование базы данных наборов символов. Добавление DB_CHARSET и DB_COLLATE в файл wp-config.php, для существующего блога, может вызвать серьезные проблемы.

База данных параметр Сравнение

As of WordPress Version 2.2, DB_COLLATE was made available to allow designation of the database collation (i.e. the sort order of the character set). In most cases, this value should be left blank (null) so the database collation will be automatically assigned by MySQL based on the database character set specified by DB_CHARSET. Set DB_COLLATE to one of the UTF-8 values defined in UTF-8 character sets для большинства западноевропейских языков.

The WordPress default DB_COLLATE value:

define('DB_COLLATE', ); 

UTF-8 Unicode General collation

define('DB_COLLATE', 'utf8_general_ci');

UTF-8 Unicode Turkish collation

define('DB_COLLATE', 'utf8_turkish_ci');
ВНИМАНИЕ: Those performing new installations

There usually should be no reason to change the default value of DB_COLLATE. Leaving the value blank (null) will insure the collation is automatically assigned by MySQL when the database tables are created.

ВНИМАНИЕ: Those performing upgrades (especially blogs that existed before 2.2)

If DB_COLLATE and DB_CHARSET do not exist in your wp-config.php file, DO NOT add either definition to your wp-config.php file unless you read and understand Converting Database Character Sets. And you may be in need of a WordPress upgrade.


Ключи безопасности

In Version 2.6, three (3) security keys, AUTH_KEY, SECURE_AUTH_KEY, and LOGGED_IN_KEY, were added to insure better encryption of information stored in the user's cookies. (These collectively replaced a single key introduced in Version 2.5.) In Version 2.7 a fourth key, NONCE_KEY, was added to this group. When each key was added, corresponding salts were added: AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, and NONCE_SALT.

You don't have to remember the keys, just make them long, random and complicated -- or better yet, use the the online generator. You can change these at any point in time to invalidate all existing cookies. This does mean that all users will have to login again.

Пример (не используйте эти значения!):

define('AUTH_KEY',         't`DK%X:>xy|e-Z(BXb/f(Ur`8#~UzUQG-^_Cs_GHs5U-&Wb?pgn^p8(2@}IcnCa|');
define('SECURE_AUTH_KEY',  'D&ovlU#|CvJ##uNq}bel+^MFtT&.b9{UvR]g%ixsXhGlRJ7q!h}XWdEC[BOKXssj');
define('LOGGED_IN_KEY',    'MGKi8Br(&{H*~&0s;{k0<S(O:+f#WM+q|npJ-+P;RDKT:~jrmgj#/-,[hOBk!ry^');
define('NONCE_KEY',        'FIsAsXJKL5ZlQo)iD-pt??eUbdc{_Cn<4!d~yqz))&B D?AwK%)+)F2aNwI|siOe');
define('AUTH_SALT',        '7T-!^i!0,w)L#JK@pc2{8XE[DenYI^BVf{L:jvF,hf}zBf883td6D;Vcy8,S)-&G');
define('SECURE_AUTH_SALT', 'I6`V|mDZq21-J|ihb u^q0F }F_NUcy`l,=obGtq*p#Ybe4a31R,r=|n#=]@]c #');
define('LOGGED_IN_SALT',   'w<$4c$Hmd%/*]`Oom>(hdXW|0M=X={we6;Mpvtg+V.o<$|#_}qG(GaVDEsn,~*4i');
define('NONCE_SALT',       'a|#h{c5|P &xWs4IZ20c2&%4!c(/uG}W:mAvy<I44`jAbup]t=]V<`}.py(wTP%%');

A secret key makes your site harder to hack and access harder to crack by adding random elements to the password.

In simple terms, a secret key is a password with elements that make it harder to generate enough options to break through your security barriers. A password like "password" or "test" is simple and easily broken. A random, unpredictable password such as "88a7da62429ba6ad3cb3c76a09641fc" takes years to come up with the right combination. A 'salt is used to further enhance the security of the generated result.

The four keys are required for the enhanced security. The four salts are recommended, but are not required, because WordPress will generate salts for you if none are provided. They are included in wp-config.php by default for inclusiveness.

For more information on the technical background and breakdown of secret keys and secure passwords, see:

Расширенные опции

The following sections may contain advanced / unsupported information, so please make sure you practice regular backups and know how to restore them before experimenting on a production installation.


префикс_таблиц

The $table_prefix is the value placed in the front of your database tables. Change the value if you want to use something other than wp_ for your database prefix. Typically this is changed if you are installing multiple WordPress blogs in the same database.

// You can have multiple installations in one database if you give each a unique prefix
$table_prefix  = 'r235_';   // Only numbers, letters, and underscores please!

A second blog installation using the same database can be achieved simply by using a different prefix than your other installations.

$table_prefix  = 'y77_';   // Only numbers, letters, and underscores please!


Адрес WordPress (URL)

WP_SITEURL, defined since WordPress Version 2.2, allows the WordPress address (URL) to be defined. The valued defined is the address where your WordPress core files reside. It should include the http:// part too. Do not put a slash "/" at the end. Setting this value in wp-config.php overrides the wp_options table value for siteurl and disables the WordPress address (URL) field in the Administration > Settings > General panel.

ЗАМЕЧАНИЕ: It won't change the Database value though, and the url will revert to the old database value if this line is removed from wp-config. Use the RELOCATE constant to change the siteurl value in the database.

If WordPress is installed into a directory called "wordpress" for the domain example.com, define WP_SITEURL like this:

define('WP_SITEURL', 'http://example.com/wordpress');

Dynamically set WP_SITEURL based on $_SERVER['HTTP_HOST']

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpressp');
ЗАМЕЧАНИЕ: A safer alternative for some installations would be to use the server-generated SERVER_NAME instead of the php/user-generated HTTP_HOST which is created dynamically by php based on the value of the HTTP HOST Header in the request, thus possibly allowing for file inclusion vulnerabilities. SERVER_NAME is set by the server configuration and is static.

Dynamically set WP_SITEURL based on $_SERVER['SERVER_NAME']

define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/path/to/wordpressp');

Адрес блога (URL)

WP_HOME is another wp-config.php option added in WordPress Version 2.2. Similar to WP_SITEURL, WP_HOME overrides the wp_options table value for home but does not change it permanently. home is the address you want people to type in their browser to reach your WordPress blog. It should include the http:// part and should not have a slash "/" at the end.

define('WP_HOME', 'http://example.com/wordpress'); 

If you are using the technique described in Giving WordPress Its Own Directory then follow the example below. Remember, you will also be placing an index.php in your web-root directory if you use a setting like this.

define('WP_HOME', 'http://example.com');

Dynamically set WP_HOME based on $_SERVER['HTTP_HOST']

define('WP_HOME',    'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpress');

Перемещение wp-content

Since Version 2.6, you can move the wp-content directory, which holds your themes, plugins, and uploads, outside of the WordPress application directory.

Set WP_CONTENT_DIR to the full local path of this directory (no trailing slash), e.g.

define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' );

Set WP_CONTENT_URL to the full URI of this directory (no trailing slash), e.g.

define( 'WP_CONTENT_URL', 'http://example/blog/wp-content');

Optional
Set WP_PLUGIN_DIR to the full local path of this directory (no trailing slash), e.g.

define( 'WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content/plugins' );

Set WP_PLUGIN_URL to the full URI of this directory (no trailing slash), e.g.

define( 'WP_PLUGIN_URL', 'http://example/blog/wp-content/plugins');

If you have compability issues with plugins Set PLUGINDIR to the full local path of this directory (no trailing slash), e.g.

define( 'PLUGINDIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content/plugins' );

Перемещение папки загрузок

Установить (к примеру) папку для загрузки медиафайлов на media:

define( 'UPLOADS', 'wp-content/media' );

Этот путь не может быть абсолютным, он всегда относителен ABSPATH, поэтому не нужно указывать слеш в начале. Константа должна быть определена до этой директивы:

 /** Sets up WordPress vars and included files. */
 require_once(ABSPATH . 'wp-settings.php');

Изменение интервала автосохранения

При редактировании статьи, WordPress использует Ajax для автоматического сохранения изменений к статье при редактировании. Вы можете увеличить этот параметр для более длительной задержки между автоматическим сохранением, или уменьшить параметр, чтобы быть уверенным, что вы никогда не потеряете изменения. По умолчанию 60 секунд.

define('AUTOSAVE_INTERVAL', 160 );  // seconds

Редакции записей

WordPress по умолчанию, будет сохранять копии каждого редактирования сделанного к статье или странице, допуская возможность возврата к предыдущей версии этой статьи или страницы. Сохранение редакций может быть отключено, или максимальное количество редакций в статье или странице может быть указано.


Отключить редакции записей

Если вы не установите это значение, WordPress по-умолчанию присвоит WP_POST_REVISIONS в true (включены редакции статей). Если вы хотите отключить потрясающее свойство редакций, используйте этот параметр:

define('WP_POST_REVISIONS', false );


Указать число редакций записи

Если вы хотите задать максимальное количество редакций, измените false на целое/число (например, 3 или 5).

define('WP_POST_REVISIONS', 3);

Установить Cookie домен

Установка домена в cookies для WordPress может быть определена для тех, кто с необычными настройками домена. Одна из причин это если субдомены используются для обслуживания статического контента. Для предотвращения отправки WordPress куков с каждым запросом к статическому контенту на вашем субдомене, вы можете установить куки только к вашему не-статическому домену.

define('COOKIE_DOMAIN', 'www.askapache.com');

Отладка

Опция WP_DEBUG, добавлена в WordPress Version 2.3.1, управляет отображением некоторых ошибок и предупреждений. Если этот параметр отсутствует в wp-config.php, то значение считается false.

ЗАМЕЧАНИЕ: Параметры true и false в примере не заключайте в апостроф (') , потому что они являются логическими значениями.
define('WP_DEBUG', true);
define('WP_DEBUG', false);

Кроме того, если вы планируете модифицировать некоторые встроенные в WordPress JavaScript`ы, следует включить следующую опцию:

define('SCRIPT_DEBUG', true);

Это позволит вам редактировать имя_скрипта.dev.js файлы в wp-includes/js и wp-admin/js каталогах.

В WordPress начиная с версии 2.3.2, ошибки базы данных печатаются только если WP_DEBUG установлен в положение true. В более ранних версиях, ошибки базы данных всегда печатались. (Ошибки базы данных обрабатываются классом wpdb и не влияют на настройки ошибок РНР.)

В WordPress версии 2.5, установка WP_DEBUG в true также поднимает уровень сообщений об ошибках на E_ALL и активирует предупреждения, когда устаревшие функции или файлы используются; в противном случае, WordPress устанавливает уровень сообщений об ошибках в E_ALL ^ E_NOTICE ^ E_USER_NOTICE.

Отключить Javascript присоединение

Чтобы результатам заканчиваться более быстрой административной областью, все файлы Javascript являются присоединёнными в один URL. Если Javascript не в состоянии работать в вашей административной области, вы можете попробовать отключить эту функцию:

define('CONCATENATE_SCRIPTS', false);

Настройка лога ошибок

Because wp-config.php is loaded for every page view not loaded from a cache file, it is an excellent location to set php ini settings that control your php installation. This is useful if you don't have access to a php.ini file, or if you just want to change some settings on the fly.

Here is an example that turns php error_logging on and logs them to a specific file. If WP_DEBUG is defined to true, the errors will also be saved to this file. Just place this above any require_once or include commands.

@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/home/example.com/logs/php_error.log');
/* That's all, stop editing! Happy blogging. */

Another example of logging errors, as suggested by Mike Little on the wp-hackers email list:

/**
 * This will log all errors notices and warnings to a file called debug.log in
 * wp-content (if Apache does not have write permission, you may need to create
 * the file first and set the appropriate permissions (i.e. use 666) ) 
 */
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

Увеличение памяти для PHP

Also released with Version 2.5, the WP_MEMORY_LIMIT option allows you to specify the maximum amount of memory that can be consumed by PHP. This setting may be necessary in the event you receive a message such as "Allowed memory size of xxxxxx bytes exhausted".

This setting increases PHP Memory only for WordPress, not other applications. By default, WordPress will attempt to increase memory allocated to PHP to 32MB (code is at beginning of wp-settings.php), so the setting in wp-config.php should reflect something higher than 32MB.

WordPress will automatically check if PHP has been allocated less memory than the entered value before utilizing this function. For example, if PHP has been allocated 64MB, there is no need to set this value to 64M as WordPress will automatically use all 64MB if need be.

Пожалуйста, обратите внимание, что этот параметр не может работать, если ваш хостинг не позволяет увеличить объем памяти PHP - в этом случае , обратитесь к хостинг провайдеру для увеличение лимита PHP памяти. Кроме того, обратите внимание, что многие хостинги устанавливают лимит для PHP на 8 МБ.

Увеличить PHP память до 64 МБ

define('WP_MEMORY_LIMIT', '64M');

Увеличить PHP память до 96 МБ

define('WP_MEMORY_LIMIT', '96M');

КЭШ

The WP_CACHE setting, if true, includes the wp-content/advanced-cache.php script, when executing wp-settings.php.

define('WP_CACHE', true);


Пользовательские таблицы и Usermeta таблицы

CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE are used to designated that the user and usermeta tables normally utilized by WordPress are not used, instead these values/tables are used to store your user information.

define('CUSTOM_USER_TABLE', $table_prefix.'my_users');
define('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta');

Язык и Языковые Директории

WPLANG defines the name of the language translation (.mo) file. WP_LANG_DIR defines what directory the WPLANG .mo file resides. If WP_LANG_DIR is not defined WordPress looks first to wp-content/languages and then wp-includes/languages for the .mo defined by WPLANG file.

define ('WPLANG', 'ru_RU'); 
define('WP_LANG_DIR', $_SERVER['DOCUMENT_ROOT'].'wordpress/languages');

Сохранение запросов для анализа

The SAVEQUERIES definition saves the database queries to a array and that array can be displayed to help analyze those queries. The information saves each query, what function called it, and how long that query took to execute.

NOTE: This will have a performance impact on your site, so make sure to turn this off when you aren't debugging.

First, put this in wp-config.php:

define('SAVEQUERIES', true);

Then in the footer of your theme put this:

<?php
if (current_user_can('administrator')){
    global $wpdb;
    echo "<pre>";
    print_r($wpdb->queries);
    echo "</pre>";
}
?>

Смена прав доступа к файлам по умолчанию

Команды FS_CHMOD_DIR и FS_CHMOD_FILE позволяют сменить права доступа к файлам и каталогам непосредственно из файла конфигурации. Это нужно, если возникает Ошибка 400. Такое может произойти на некоторых хостингах. Первая команда установит права доступа к каталогам на '0755' Вторая установит права доступа к файлам на '0644'. Не забудьте знак ('). Еще информация: Changing File Permissions

define('FS_CHMOD_DIR', (0755 & ~ umask()));
define('FS_CHMOD_FILE', (0644 & ~ umask()));

Константы для обновления WordPress

You should define as few of the below constants needed to correct your update issues.

The most common causes of needing to define these are:

  • Host running with a special installation setup involving Symlinks, You may need to define the path-related constants (FTP_BASE, FTP_CONTENT_DIR, and FTP_PLUGIN_DIR), Often defining simply the base will be enough.
  • Certain PHP installations shiped with a PHP FTP Extension which is incompatible with certain FTP Servers, under these rare situations, you may need to define FTP_METHOD to 'ftpsockets'

The following are valid constants for WordPress updates:

  • FS_METHOD forces the filesystem method. It should only be "direct", "ssh", "ftpext", or "ftpsockets". Generally, You should only change this if you are experiencing update problems, If you change it, and it doesnt help change it back/remove it, Under most circumstances, setting it to 'ftpsockets' will work if the automatically chosen method does not.
    • (Primary Preference) "Direct" forces it to use Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts, This is chosen automatically when appropriate.
    • (Secondary Preference) "ssh" is to force the usage of the SSH PHP Extension.
    • (3rd Preference) "ftpext" is to force the usage of the FTP PHP Extension for FTP Access, and finally
    • (4th Preference) "ftpsockets" utilises the PHP Sockets Class for FTP Access.
  • FTP_BASE is the full path to the "base"(ABSPATH) folder of the WordPress installation.
  • FTP_CONTENT_DIR is the full path to the wp-content folder of the WordPress installation.
  • FTP_PLUGIN_DIR is the full path to the plugins folder of the WordPress installation.
  • FTP_PUBKEY is the full path to your SSH public key.
  • FTP_PRIKEY is the full path to your SSH private key.
  • FTP_USER is either user FTP or SSH username. Most likely these are the same, but use the appropriate one for the type of update you wish to do.
  • FTP_PASS is the password for the username entered for FTP_USER. If you are using SSH public key authentication this can be omitted.
  • FTP_HOST is the hostname:port combination for your SSH/FTP server. The default FTP port is 21 and the default SSH port is 22, These do not need to be mentioned.
  • FTP_SSL TRUE for SSL-connection if supported by the underlying transport, Not available on all servers. This is for "Secure FTP" not for SSH SFTP.
define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/path/to/wordpress/');
define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/');
define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub');
define('FTP_PRIKEY', '/home/username/.ssh/id_rsa');
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', 'ftp.example.org');
define('FTP_SSL', false);


Включение SSH Обновление доступа

To enable SSH2 as an upgrade option you will need to install the pecl SSH2 extension. To install this library you will need to issue a command similar to the following or talk to your web hosting provider to get this installed:

pecl install ssh2

After installing the pecl ssh2 extension you will need to modify your php configuration to automatically load this extension.

pecl is provided by the pear package in most linux distributions. To install pecl in Redhat/Fedora/CentOS:

yum -y install php-pear

To install pecl in Debian/Ubuntu:

apt-get install php-pear

It is recommended to use a private key that is not pass-phrase protected. There have been numerous reports that pass phrase protected private keys do not work properly. If you decide to try a pass phrase protected private key you will need to enter the pass phrase for the private key as FTP_PASS, or entering it in the "Password" field in the presented credential field when installing updates.

If you're still not clear on how to use SSH for upgrading or installing WordPress/plugins, read through this tutorial.

Альтернатива Cron

Use this, for example, if scheduled posts are not getting published. According to Otto's forum explanation, "this alternate method uses a redirection approach, which makes the users browser get a redirect when the cron needs to run, so that they come back to the site immediately while cron continues to run in the connection they just dropped. This method is a bit iffy sometimes, which is why it's not the default."

define('ALTERNATE_WP_CRON', true);


Дополнительно задаваемые константы

Here are additional constants that can be defined, but probably shouldn't be. The Cookie definitions are particularly useful if you have an unusual domain setup.

define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL)  );
define('TEMPLATEPATH', get_template_directory());
define('STYLESHEETPATH', get_stylesheet_directory());
define('DISABLE_WP_CRON', true);

Очистка корзины

Added with Version 2.9, this constant controls the number of days before WordPress permanently deletes posts, pages, attachments, and comments, from the trash bin. The default is 30 days:

define('EMPTY_TRASH_DAYS', 30 );  // 30 days

To disable trash set the number of days to zero. Note that WordPress will not ask for confirmation when someone clicks on "Delete Permanently".

define('EMPTY_TRASH_DAYS', 0 );  // zero days

Автоматическая оптимизация базы данных

Added with Version 2.9, there is automatic database optimization support, which you can enable by adding the following define to your wp-config.php file only when the feature is required

 define('WP_ALLOW_REPAIR', true);

The script can be found at {$your_site}/wp-admin/maint/repair.php

Please Note: That this define enables the functionality, The user does not need to be logged in to access this functionality when this define is set. This is because its main intent is to repair a corrupted database, Users can often not login when the database is corrupt.

Просмотр всех определенных констант

Php has a function that returns an array of all the currently defined constants with their values.

 print_r(@get_defined_constants());

Дважды проверьте перед сохранением

Be sure to check for leading and/or trailing spaces around any of the above values you entered, and DON'T delete the single quotes!

Before you save the file, be sure to double-check that you have not accidentally deleted any of the single quotes around the parameter values. Be sure there is nothing after the closing PHP tag in the file. The last thing in the file should be ?> and nothing else. No spaces.

To save the file, choose File > Save As > wp-config.php and save the file in the root of your WordPress install. Upload the file to your web server and you're ready to install WordPress!


Смотрите так же