编辑“WordPress:Editing wp-config.php”
该编辑可以被撤销。 请检查下面的对比以核实您想要撤销的内容,然后发布下面的更改以完成撤销。
最后版本 | 您的文本 | ||
第1行: | 第1行: | ||
As part of the WordPress installation, you must modify the <tt>wp-config.php</tt> file to define the WordPress configuration settings required to access your MySQL database. | As part of the WordPress installation, you must modify the <tt>wp-config.php</tt> file to define the WordPress configuration settings required to access your MySQL database. | ||
This file, <tt>wp-config.php</tt>, does not exist in a downloaded copy of WordPress; you need to create it. The <tt>wp-config-sample.php</tt> file is provided as an example to work from. | This file, <tt>wp-config.php</tt>, does not exist in a downloaded copy of WordPress; you need to create it. The <tt>wp-config-sample.php</tt> file is provided as an example to work from. | ||
Since [[WordPress:Version 2.6]], wp-config can be moved to the directory directly above the WordPress application directory. | Since [[WordPress:Version 2.6]], wp-config can be moved to the directory directly above the WordPress application directory. | ||
To change the <tt>wp-config.php</tt> file for your installation, you will need this information: | To change the <tt>wp-config.php</tt> file for your installation, you will need this information: | ||
* Database Name | * Database Name | ||
第19行: | 第11行: | ||
* Database Password | * Database Password | ||
* Database Host | * Database Host | ||
If your hosting provider installed WordPress for you, get the information from them. If you manage your own web server or hosting account, you will have this information as a result of creating the database and user (see [[WordPress:Installing_WordPress#Step_2:_Create_the_Database_and_a_User|Installing WordPress, Create the Database and User]]). | If your hosting provider installed WordPress for you, get the information from them. If you manage your own web server or hosting account, you will have this information as a result of creating the database and user (see [[WordPress:Installing_WordPress#Step_2:_Create_the_Database_and_a_User|Installing WordPress, Create the Database and User]]). | ||
== Creating the file == | == Creating the file == | ||
Open the file <tt>wp-config-sample.php</tt> in a [[WordPress:Glossary#Text_editor|text editor]]. | Open the file <tt>wp-config-sample.php</tt> in a [[WordPress:Glossary#Text_editor|text editor]]. | ||
'''Important:''' ''never'' use a word processor like Microsoft Word for editing WordPress files! | '''Important:''' ''never'' use a word processor like Microsoft Word for editing WordPress files! | ||
=== Database name === | === Database name === | ||
Find the line that says: | Find the line that says: | ||
define('DB_NAME', 'putyourdbnamehere'); // The name of the database | define('DB_NAME', 'putyourdbnamehere'); // The name of the database | ||
('''NOTE:''' Everything on these lines you see after the <tt>//</tt> are comments for information purposes only.) | ('''NOTE:''' Everything on these lines you see after the <tt>//</tt> are comments for information purposes only.) | ||
Where it says <tt>'putyourdbnamehere'</tt>, delete ''putyourdbnamehere'' and enter the name of your database. '''Make sure that you don't accidentally delete the single quotation marks!''' | Where it says <tt>'putyourdbnamehere'</tt>, delete ''putyourdbnamehere'' and enter the name of your database. '''Make sure that you don't accidentally delete the single quotation marks!''' | ||
The line should look like this: | The line should look like this: | ||
define('DB_NAME', 'myDatabasename'); // The name of the database | define('DB_NAME', 'myDatabasename'); // The name of the database | ||
=== Database user name === | === Database user name === | ||
define('DB_USER', 'usernamehere'); // Your MySQL username | define('DB_USER', 'usernamehere'); // Your MySQL username | ||
Delete ''usernamehere'' and enter in your own username: | Delete ''usernamehere'' and enter in your own username: | ||
define('DB_USER', 'myDatabaseUser'); // Your MySQL username | define('DB_USER', 'myDatabaseUser'); // Your MySQL username | ||
=== Database password === | === Database password === | ||
On to the next one: | On to the next one: | ||
define('DB_PASSWORD', 'yourpasswordhere'); // ...and password | define('DB_PASSWORD', 'yourpasswordhere'); // ...and password | ||
Delete ''yourpasswordhere'' and enter in your MySQL password: | Delete ''yourpasswordhere'' and enter in your MySQL password: | ||
define('DB_PASSWORD', 'MyOwnPassword'); // ...and password | define('DB_PASSWORD', 'MyOwnPassword'); // ...and password | ||
This is only an example password, of course! :) | This is only an example password, of course! :) | ||
===Database host=== | ===Database host=== | ||
The next line under the password line defines the host for your database. There is a 99% chance you will '''NOT''' have to change it unless your web host tells you otherwise. In other words, you can likely leave it as the default value of <tt>'localhost'</tt>. | The next line under the password line defines the host for your database. There is a 99% chance you will '''NOT''' have to change it unless your web host tells you otherwise. In other words, you can likely leave it as the default value of <tt>'localhost'</tt>. | ||
If your database host is different than <tt>'localhost'</tt>, move down to the next line: | If your database host is different than <tt>'localhost'</tt>, move down to the next line: | ||
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value | define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value | ||
Delete ''localhost'' and enter in your database host as directed by your web host: | Delete ''localhost'' and enter in your database host as directed by your web host: | ||
define('DB_HOST', 'mysql34.myhostserver'); // 99% chance you won't need to change this value | define('DB_HOST', 'mysql34.myhostserver'); // 99% chance you won't need to change this value | ||
Of course, the '''mysql34.myhostserver''' will be different for you. | Of course, the '''mysql34.myhostserver''' will be different for you. | ||
====Possible DB_HOST values==== | ====Possible DB_HOST values==== | ||
Some possible DB_HOST values for hosting companies: | Some possible DB_HOST values for hosting companies: | ||
* 1and1 - something similar to <tt>db12345678</tt> | * 1and1 - something similar to <tt>db12345678</tt> | ||
第141行: | 第73行: | ||
* Hosts with cPanel - <tt>localhost</tt> | * Hosts with cPanel - <tt>localhost</tt> | ||
* Hosts with Plesk - <tt>localhost</tt> | * Hosts with Plesk - <tt>localhost</tt> | ||
====Mysql Alternate Port==== | ====Mysql Alternate Port==== | ||
Also if your database host uses an alternate port number you'll need to change to reflect the alternate port: | Also if your database host uses an alternate port number you'll need to change to reflect the alternate port: | ||
define('DB_HOST', 'mysql34.myhostserver:3307'); // 99% chance you won't need to change this value | define('DB_HOST', 'mysql34.myhostserver:3307'); // 99% chance you won't need to change this value | ||
You'll need to change 3307 to reflect what your host provides you as the alternate port number. | You'll need to change 3307 to reflect what your host provides you as the alternate port number. | ||
=== Secret keys (2.6) === | === Secret keys (2.6) === | ||
[[WordPress:Version 2.6]] has 3 secret keys: AUTH_KEY, SECURE_AUTH_KEY, and LOGGED_IN_KEY. | [[WordPress:Version 2.6]] has 3 secret keys: AUTH_KEY, SECURE_AUTH_KEY, and LOGGED_IN_KEY. | ||
You don't have to remember them, so make them long and complicated. Make something up or use [http://api.wordpress.org/secret-key/1.1/ the secret key generator]. Example: | |||
Example: | |||
define('AUTH_KEY', ':dr+%/5V4sAUG-gg%aS*v;&xGhd%{YKC^Z7KKGh j>k[.Nf$y7iGKdJ3c*[Kr5Bg'); | define('AUTH_KEY', ':dr+%/5V4sAUG-gg%aS*v;&xGhd%{YKC^Z7KKGh j>k[.Nf$y7iGKdJ3c*[Kr5Bg'); | ||
第220行: | 第93行: | ||
===Secret Key (2.5; IMPORTANT)=== | ===Secret Key (2.5; IMPORTANT)=== | ||
'''It is most important to change the default SECRET_KEY value to something other than 'put your unique phrase here'.''' Visit the [http://api.wordpress.org/secret-key/1.0/ WordPress secret key generation site] to get a SECRET_KEY generated for you. | '''It is most important to change the default SECRET_KEY value to something other than 'put your unique phrase here'.''' Visit the [http://api.wordpress.org/secret-key/1.0/ WordPress secret key generation site] to get a SECRET_KEY generated for you. | ||
Released with [[WordPress:Version 2.5]], this new, optional entry, called '''SECRET_KEY''', causes better encryption of information stored in the user's cookies. The secret key is a unique phrase. | Released with [[WordPress:Version 2.5]], this new, optional entry, called '''SECRET_KEY''', causes better encryption of information stored in the user's cookies. The secret key is a unique phrase. | ||
<pre> | <pre> | ||
第237行: | 第102行: | ||
// to get a phrase generated for you, or just make something up. | // to get a phrase generated for you, or just make something up. | ||
define('SECRET_KEY', 'put your unique phrase here'); // Change this to a unique phrase. </pre> | define('SECRET_KEY', 'put your unique phrase here'); // Change this to a unique phrase. </pre> | ||
Here's a detailed explanation on the wp-hackers email list from Mark Jaquith in response to the question, "What is the SECRET_KEY for?" | Here's a detailed explanation on the wp-hackers email list from Mark Jaquith in response to the question, "What is the SECRET_KEY for?" | ||
<blockquote> | <blockquote> | ||
It is a hashing salt that is not readable through the database. "And what is a salt?" A salt is something that adds randomness to a hash input and makes it much harder to crack. For example:<br /> | It is a hashing salt that is not readable through the database. "And what is a salt?" A salt is something that adds randomness to a hash input and makes it much harder to crack. For example:<br /> | ||
<br /> | <br /> | ||
In these examples, consider that the password is "test", but that the cracker does not know this (indeed, this is what he's trying to determine). And yes, I'm glossing over some stuff, but this is the simplistic explanation.<br /> | In these examples, consider that the password is "test", but that the cracker does not know this (indeed, this is what he's trying to determine). And yes, I'm glossing over some stuff, but this is the simplistic explanation.<br /> | ||
<br /> | <br /> | ||
Easy to crack: md5('test');<br /> | Easy to crack: md5('test');<br /> | ||
<br /> | <br /> | ||
Since 'test' is a short dictionary word, crackers who have the output hash can easily use rainbow tables (dictionary lookup table) to crack that password in seconds, or minutes.<br /> | Since 'test' is a short dictionary word, crackers who have the output hash can easily use rainbow tables (dictionary lookup table) to crack that password in seconds, or minutes.<br /> | ||
<br /> | <br /> | ||
Harder to crack: md5('test' . $known_salt);<br /> | Harder to crack: md5('test' . $known_salt);<br /> | ||
<br /> | <br /> | ||
In this case, the cracker has to generate a new rainbow table that adds the $known_salt value to their table's hashes. This slows them down.<br /> | In this case, the cracker has to generate a new rainbow table that adds the $known_salt value to their table's hashes. This slows them down.<br /> | ||
<br /> | <br /> | ||
Even harder to crack: md5('test' . $unknown_salt);<br /> | Even harder to crack: md5('test' . $unknown_salt);<br /> | ||
<br /> | <br /> | ||
In this case, they don't know the salt. And since a good salt is something very random, like "888a7da62429ba6ad3cb3c76a09641fc" -- they can't use rainbow tables to help them. They have to just "brute force" their way through all the possible combinations. This is a huge hurdle. Something that might take 10 minutes before could now take years. | In this case, they don't know the salt. And since a good salt is something very random, like "888a7da62429ba6ad3cb3c76a09641fc" -- they can't use rainbow tables to help them. They have to just "brute force" their way through all the possible combinations. This is a huge hurdle. Something that might take 10 minutes before could now take years. | ||
</blockquote> | </blockquote> | ||
===Database character set=== | ===Database character set=== | ||
As of WordPress [[WordPress:Version 2.2|Version 2.2]], '''DB_CHARSET''' was made available to allow designation of the database [[WordPress:Glossary#Character Set|character set]] (e.g. tis620 for TIS620 Thai) to be used when defining the MySQL database tables. The default value of '''utf8''' ([[WordPress:Wikipedia:Unicode|Unicode]] [[WordPress:Wikipedia:UTF-8|UTF-8]]) should NOT BE CHANGED without careful understanding of the outcome. Please note that UTF-8 supports many European languages so leave DB_CHARSET at '''utf8''' and use the appropriate [[WordPress:#Database collation|DB COLLATE]] value for your language. | As of WordPress [[WordPress:Version 2.2|Version 2.2]], '''DB_CHARSET''' was made available to allow designation of the database [[WordPress:Glossary#Character Set|character set]] (e.g. tis620 for TIS620 Thai) to be used when defining the MySQL database tables. The default value of '''utf8''' ([[WordPress:Wikipedia:Unicode|Unicode]] [[WordPress:Wikipedia:UTF-8|UTF-8]]) should NOT BE CHANGED without careful understanding of the outcome. Please note that UTF-8 supports many European languages so leave DB_CHARSET at '''utf8''' and use the appropriate [[WordPress:#Database collation|DB COLLATE]] value for your language. | ||
*'''Warning for those performing new installations''': For most Western European languages, including English, there usually should be no reason to change the default value of DB_CHARSET. If your blog needs a different character set, please read [http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html Character Sets and Collations That MySQL Supports] for the valid values for DB_CHARSET. | *'''Warning for those performing new installations''': For most Western European languages, including English, there usually should be no reason to change the default value of DB_CHARSET. If your blog needs a different character set, please read [http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html Character Sets and Collations That MySQL Supports] for the valid values for DB_CHARSET. | ||
*'''Warning for those performing upgrades''': If DB_CHARSET and DB_COLLATE do not exist in your <tt>wp-config.php</tt> file, DO NOT add either definition to your <tt>wp-config.php</tt> file unless you read and understand [[WordPress:Converting Database Character Sets]]. Adding DB_CHARSET and DB_COLLATE to the <tt>wp-config.php</tt> file, for an existing blog, can cause problems — as Ryan Boren says, "your queries will go boom!" | *'''Warning for those performing upgrades''': If DB_CHARSET and DB_COLLATE do not exist in your <tt>wp-config.php</tt> file, DO NOT add either definition to your <tt>wp-config.php</tt> file unless you read and understand [[WordPress:Converting Database Character Sets]]. Adding DB_CHARSET and DB_COLLATE to the <tt>wp-config.php</tt> file, for an existing blog, can cause problems — as Ryan Boren says, "your queries will go boom!" | ||
This example shows utf8 which is considered the WordPress default value: | This example shows utf8 which is considered the WordPress default value: | ||
define('DB_CHARSET', 'utf8'); | define('DB_CHARSET', 'utf8'); | ||
===Database collation=== | ===Database collation=== | ||
As of WordPress [[WordPress:Version 2.2|Version 2.2]], '''DB_COLLATE''' was made available to allow designation of the database [[WordPress:Glossary#Collation|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 (i.e. DB_CHARSET). Set '''DB_COLLATE''' to one of the UTF-8 values defined in [http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html Unicode character sets (utf8 section)] for most Western European languages. | As of WordPress [[WordPress:Version 2.2|Version 2.2]], '''DB_COLLATE''' was made available to allow designation of the database [[WordPress:Glossary#Collation|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 (i.e. DB_CHARSET). Set '''DB_COLLATE''' to one of the UTF-8 values defined in [http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html Unicode character sets (utf8 section)] for most Western European languages. | ||
*'''Warning for 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. | *'''Warning for 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. | ||
*'''Warning for those performing upgrades''': If DB_COLLATE and DB_CHARSET do not exist in your <tt>wp-config.php</tt> file, DO NOT add either definition to your <tt>wp-config.php</tt> file unless you read and understand [[WordPress:Converting Database Character Sets]]. Adding DB_COLLATE and DB_CHARSET to the <tt>wp-config.php</tt> file, for an existing blog, can cause problems — as Ryan Boren says, "your queries will go boom!" | *'''Warning for those performing upgrades''': If DB_COLLATE and DB_CHARSET do not exist in your <tt>wp-config.php</tt> file, DO NOT add either definition to your <tt>wp-config.php</tt> file unless you read and understand [[WordPress:Converting Database Character Sets]]. Adding DB_COLLATE and DB_CHARSET to the <tt>wp-config.php</tt> file, for an existing blog, can cause problems — as Ryan Boren says, "your queries will go boom!" | ||
<!-- | <!-- | ||
*'''Further warning for those upgrading to WP 2.3.x''': You cannot upgrade from a pre-2.3 version of WordPress with these lines in your wp-config.php file. The upgrade to 2.3.x moves data from the wp_categories table to the wp_terms table, and deletes the former. This cannot happen if the DB_COLLATE and DB_CHARSET lines are included. More info [http://wordpress.org/support/topic/150460 in the forums] and [http://www.webbleyou.com/2008-02-25-wordpress-23x-upgrade-error-tables-wp_terms-and-wp_term_taxonomy-dont-exist/ this blog post]. | *'''Further warning for those upgrading to WP 2.3.x''': You cannot upgrade from a pre-2.3 version of WordPress with these lines in your wp-config.php file. The upgrade to 2.3.x moves data from the wp_categories table to the wp_terms table, and deletes the former. This cannot happen if the DB_COLLATE and DB_CHARSET lines are included. More info [http://wordpress.org/support/topic/150460 in the forums] and [http://www.webbleyou.com/2008-02-25-wordpress-23x-upgrade-error-tables-wp_terms-and-wp_term_taxonomy-dont-exist/ this blog post]. | ||
--> | --> | ||
This example is of the WordPress default DB_COLLATE value: | |||
define('DB_COLLATE', ''); | define('DB_COLLATE', ''); | ||
*Example if UTF-8 Unicode Turkish collation is needed (DB_CHARSET should be utf8): | *Example if UTF-8 Unicode Turkish collation is needed (DB_CHARSET should be utf8): | ||
define('DB_COLLATE', 'utf8_turkish_ci'); | define('DB_COLLATE', 'utf8_turkish_ci'); | ||
===$table_prefix=== | ===$table_prefix=== | ||
The $table_prefix is the value placed in the front of your database tables. Change the value if you want to use something different than '''wp_''' for your database prefix. Typically this is changed if you are [[WordPress:Installing Multiple Blogs|installing multiple WordPress blogs]] in the same database. | The $table_prefix is the value placed in the front of your database tables. Change the value if you want to use something different than '''wp_''' for your database prefix. Typically this is changed if you are [[WordPress:Installing Multiple Blogs|installing multiple WordPress blogs]] in the same database. | ||
==Advanced Options== | ==Advanced Options== | ||
===WordPress address (URL)=== | ===WordPress address (URL)=== | ||
Another new <tt>wp-config.php</tt> option, added as of WordPress [[WordPress:Version 2.2|Version 2.2]], is '''WP_SITEURL'''. This allows the WordPress address (URL) to be defined. The valued defined is the address where your WordPress core files reside. It should include the <nowiki>http://</nowiki> part too. Do not put a slash "'''/'''" at the end. Setting this value in <tt>wp-config.php</tt> overrides the [[WordPress:Database_Description#Table:_wp_options|wp_options table]] value for '''siteurl''' and disables the WordPress address (URL) field in the [[WordPress:Administration_Panels|Administration]] > [[WordPress:Administration_Panels#General|Settings]] > [[WordPress:Settings_General_SubPanel|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. | Another new <tt>wp-config.php</tt> option, added as of WordPress [[WordPress:Version 2.2|Version 2.2]], is '''WP_SITEURL'''. This allows the WordPress address (URL) to be defined. The valued defined is the address where your WordPress core files reside. It should include the <nowiki>http://</nowiki> part too. Do not put a slash "'''/'''" at the end. Setting this value in <tt>wp-config.php</tt> overrides the [[WordPress:Database_Description#Table:_wp_options|wp_options table]] value for '''siteurl''' and disables the WordPress address (URL) field in the [[WordPress:Administration_Panels|Administration]] > [[WordPress:Administration_Panels#General|Settings]] > [[WordPress:Settings_General_SubPanel|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. | ||
If you have installed WordPress into a directory called "wordpress" in a [http://en.wikipedia.org/wiki/Domain_name_system domain name] called "example.com", define WP_SITEURL as this example does: | If you have installed WordPress into a directory called "wordpress" in a [http://en.wikipedia.org/wiki/Domain_name_system domain name] called "example.com", define WP_SITEURL as this example does: | ||
define('WP_SITEURL', 'http://example.com/wordpress'); | define('WP_SITEURL', 'http://example.com/wordpress'); | ||
===Blog address (URL)=== | ===Blog address (URL)=== | ||
'''WP_HOME''' is another <tt>wp-config.php</tt> option added in WordPress [[WordPress:Version 2.2|Version 2.2]]. Similar to WP_SITEURL, WP_HOME overrides the [[WordPress:Database_Description#Table:_wp_options|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 <nowiki>http://</nowiki> part. Also, do not put a slash "'''/'''" at the end. | '''WP_HOME''' is another <tt>wp-config.php</tt> option added in WordPress [[WordPress:Version 2.2|Version 2.2]]. Similar to WP_SITEURL, WP_HOME overrides the [[WordPress:Database_Description#Table:_wp_options|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 <nowiki>http://</nowiki> part. Also, do not put a slash "'''/'''" at the end. | ||
define('WP_HOME', 'http://example.com/wordpress'); | define('WP_HOME', 'http://example.com/wordpress'); | ||
If you are using the technique described in [[WordPress:Giving_WordPress_Its_Own_Directory|Giving WordPress Its Own Directory]] then follow the example below. Remember, you will also be placing an <tt>index.php</tt> in your web-root directory if you use a setting like this. | If you are using the technique described in [[WordPress:Giving_WordPress_Its_Own_Directory|Giving WordPress Its Own Directory]] then follow the example below. Remember, you will also be placing an <tt>index.php</tt> in your web-root directory if you use a setting like this. | ||
define('WP_HOME', 'http://example.com'); | define('WP_HOME', 'http://example.com'); | ||
=== Moving <tt>wp-content</tt> === | === Moving <tt>wp-content</tt> === | ||
Since [[WordPress:Version 2.6]], you can move the <tt>wp-content</tt> directory, which holds your themes, plugins, and uploads, outside of the WordPress application directory. | Since [[WordPress:Version 2.6]], you can move the <tt>wp-content</tt> directory, which holds your themes, plugins, and uploads, outside of the WordPress application directory. | ||
Set <var>WP_CONTENT_DIR</var> to the full local path of this directory (no trailing slash), e.g. | Set <var>WP_CONTENT_DIR</var> to the full local path of this directory (no trailing slash), e.g. | ||
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' ); | define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' ); | ||
Set <var>WP_CONTENT_URL</var> to the full URI of this directory (no trailing slash), e.g. | Set <var>WP_CONTENT_URL</var> to the full URI of this directory (no trailing slash), e.g. | ||
define( 'WP_CONTENT_URL', 'http://example/blog/wp-content'); | define( 'WP_CONTENT_URL', 'http://example/blog/wp-content'); | ||
===Debug=== | ===Debug=== | ||
define('WP_DEBUG', true); | define('WP_DEBUG', true); | ||
define('WP_DEBUG', false); | define('WP_DEBUG', false); | ||
The <tt>WP_DEBUG</tt> option, added in WordPress [[WordPress:Version 2.3.1|Version 2.3.1]], controls the display of some errors and warnings. If this setting is absent from <tt>wp-config.php</tt>, then the value is assumed to be <var>false</var>. Note that the <var>true</var> and <var>false</var> values are not set in apostrophes ('). | The <tt>WP_DEBUG</tt> option, added in WordPress [[WordPress:Version 2.3.1|Version 2.3.1]], controls the display of some errors and warnings. If this setting is absent from <tt>wp-config.php</tt>, then the value is assumed to be <var>false</var>. Note that the <var>true</var> and <var>false</var> values are not set in apostrophes ('). | ||
[http://trac.wordpress.org/ticket/5473 In Wordpress versions since 2.3.2, database errors are printed only if WP_DEBUG is set to <var>true</var>]. In earlier versions, database errors were always printed. (Database errors are handled by the wbdb class and are not affected by [http://www.php.net/errorfunc PHP's error settings].) | [http://trac.wordpress.org/ticket/5473 In Wordpress versions since 2.3.2, database errors are printed only if WP_DEBUG is set to <var>true</var>]. In earlier versions, database errors were always printed. (Database errors are handled by the wbdb class and are not affected by [http://www.php.net/errorfunc PHP's error settings].) | ||
In WordPress version 2.5, setting WP_DEBUG to <var>true</var> also raises the [http://www.php.net/error-reporting error reporting level] to E_ALL and activates warnings when deprecated functions or files are used; otherwise, WordPress sets the error reporting level to <tt>E_ALL ^ E_NOTICE ^ E_USER_NOTICE</tt>. | In WordPress version 2.5, setting WP_DEBUG to <var>true</var> also raises the [http://www.php.net/error-reporting error reporting level] to E_ALL and activates warnings when deprecated functions or files are used; otherwise, WordPress sets the error reporting level to <tt>E_ALL ^ E_NOTICE ^ E_USER_NOTICE</tt>. | ||
===Increasing memory allocated to PHP=== | ===Increasing memory allocated to PHP=== | ||
Also released with [[WordPress: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". | Also released with [[WordPress: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. | 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. | ||
Please note, this setting may not work if your host does not allow for increasing the PHP memory limit--in that event, contact your host to increase the PHP memory limit. Also, note that many hosts set the PHP limit at 8MB. | Please note, this setting may not work if your host does not allow for increasing the PHP memory limit--in that event, contact your host to increase the PHP memory limit. Also, note that many hosts set the PHP limit at 8MB. | ||
Increase PHP Memory to 64MB | Increase PHP Memory to 64MB | ||
<pre>define('WP_MEMORY_LIMIT', '64M');</pre> | <pre>define('WP_MEMORY_LIMIT', '64M');</pre> | ||
Increase PHP Memory to 96MB | Increase PHP Memory to 96MB | ||
<pre>define('WP_MEMORY_LIMIT', '96M');</pre> | <pre>define('WP_MEMORY_LIMIT', '96M');</pre> | ||
===Cache=== | ===Cache=== | ||
The '''WP_CACHE''' setting, if true, includes the <tt>wp-content/advanced-cache.php</tt> script, when executing <tt>wp-settings.php</tt>. | The '''WP_CACHE''' setting, if true, includes the <tt>wp-content/advanced-cache.php</tt> script, when executing <tt>wp-settings.php</tt>. | ||
<pre>define('WP_CACHE', true); </pre> | <pre>define('WP_CACHE', true); </pre> | ||
===Custom User and Usermeta Tables=== | ===Custom User and Usermeta Tables=== | ||
'''CUSTOM_USER_TABLE''' and '''CUSTOM_USER_META_TABLE''' are used to designated that the user and usermeta tables normally utilized by WordPress are instead, these values. | '''CUSTOM_USER_TABLE''' and '''CUSTOM_USER_META_TABLE''' are used to designated that the user and usermeta tables normally utilized by WordPress are instead, these values. | ||
<pre>define('CUSTOM_USER_TABLE', $table_prefix.'my_users');</pre> | <pre>define('CUSTOM_USER_TABLE', $table_prefix.'my_users');</pre> | ||
<pre>define('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta');</pre> | <pre>define('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta');</pre> | ||
===Language and Language Directory=== | ===Language and Language Directory=== | ||
'''WPLANG''' defines the name of the language translation (.mo) file. '''LANGDIR''' defines what directory the WPLANG .mo file resides. If LANGDIR is not defined WordPress looks first to wp-content/languages and then wp-includes/languages for the .mo defined by WPLANG file. | '''WPLANG''' defines the name of the language translation (.mo) file. '''LANGDIR''' defines what directory the WPLANG .mo file resides. If LANGDIR is not defined WordPress looks first to wp-content/languages and then wp-includes/languages for the .mo defined by WPLANG file. | ||
<pre>define('WPLANG', 'de_DE');</pre> | <pre>define('WPLANG', 'de_DE');</pre> | ||
<pre>define('LANGDIR', 'mylanguagedirectory');</pre> | <pre>define('LANGDIR', 'mylanguagedirectory');</pre> | ||
===Save queries for analysis=== | ===Save queries for analysis=== | ||
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. | 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. | ||
First, put this in wp-config.php: | First, put this in wp-config.php: | ||
<pre>define('SAVEQUERIES', true);</pre> | <pre>define('SAVEQUERIES', true);</pre> | ||
Then in the footer of your theme put this: | Then in the footer of your theme put this: | ||
<pre> | <pre> | ||
<? | <? | ||
第571行: | 第241行: | ||
The code above uses the switch_themes capability so only visitors with that capability will see the query results. | The code above uses the switch_themes capability so only visitors with that capability will see the query results. | ||
==Double Check Before Saving== | ==Double Check Before Saving== | ||
'''''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!''''' | '''''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. | 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! | 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! | ||
== wp-config.php with Multiple Blogs == | == wp-config.php with Multiple Blogs == | ||
Multiple WordPress blogs require special handling of their configuration files. Check [[WordPress:Installing Multiple Blogs]] for more information. | Multiple WordPress blogs require special handling of their configuration files. Check [[WordPress:Installing Multiple Blogs]] for more information. | ||