个人工具
名字空间
变换
操作

WordPress:Editing wp-config.php

来自站长百科
跳转到: 导航, 搜索

As part of the WordPress installation, you must modify the wp-config.php file to define the WordPress configuration settings required to access your MySQL database.

安装WordPress的时候,你必须更改wp-config.php文件,定义必须的WordPress配置设置,能够使用你的MySQL数据库。

This file, wp-config.php, does not exist in a downloaded copy of WordPress; you need to create it. The wp-config-sample.php file is provided as an example to work from.

wp-config.php不存在在,下载的WordPress软件包中,因此你需要创建这个文件。提供wp-config-sample.php文件,作为创建wp-config.php文件的一个例子。

Since WordPress:Version 2.6, wp-config can be moved to the directory directly above the WordPress application directory.

2.6版本开始,wp-config被移到了WordPress应用软件的上次目录。

To change the wp-config.php file for your installation, you will need this information:

要更改wp-config.php 文件,安装WordPress,你需要这个信息:

  • Database Name
  • Database Username
  • Database Password
  • 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 Installing WordPress, Create the Database and User).

如果你的主机供应商为你安装WordPress,请向这些供应商索取这些信息。如果你管理自己的网络服务器或者主机帐户,创建数据库和用户的时候,你就得到了这些信息(请看看安装WordPress, 创建数据库和用户)。

目录

Creating the file

创建文件

Open the file wp-config-sample.php in a text editor. 在一个文本编辑器中打开文件wp-config-sample.php

Important: never use a word processor like Microsoft Word for editing WordPress files!

注意: 千万别使用文字处理器,如Microsoft Word 编辑WordPress文件!

Database name

数据库名

Find the line that says:

找到这一行:

define('DB_NAME', 'putyourdbnamehere'); // The name of the database

define('DB_NAME', 'putyourdbnamehere'); // 数据库名称

(NOTE: Everything on these lines you see after the // are comments for information purposes only.)

(注:这一行中 // 后面的内容,这是评论注释。)

Where it says 'putyourdbnamehere', delete putyourdbnamehere and enter the name of your database. Make sure that you don't accidentally delete the single quotation marks!

'putyourdbnamehere'的位置,删除putyourdbnamehere并且输入你的数据库的名称。确定你没有错删了一些单引号!

The line should look like this: 看起来像:

define('DB_NAME', 'myDatabasename'); // The name of the database

define('DB_NAME', 'myDatabasename'); // 数据库名

Database user name

数据库用户名

define('DB_USER', 'usernamehere'); // Your MySQL username

Delete usernamehere and enter in your own username:

定义('DB_USER', 'usernamehere'); // 你的MySQL 用户名 删除 usernamehere 并且输入你自己的用户名:


define('DB_USER', 'myDatabaseUser'); // Your MySQL username

定义('DB_USER', 'myDatabaseUser'); // 你的 MySQL 用户名

Database password

数据库密码

On to the next one:

另一个:

define('DB_PASSWORD', 'yourpasswordhere'); // ...and password

Delete yourpasswordhere and enter in your MySQL password:

define('DB_PASSWORD', 'MyOwnPassword'); // ...and password

定义('DB_PASSWORD', 'yourpasswordhere'); // ...和密码 删除 yourpasswordhere 并且输入你自己的 MySQL 密码:

定义('DB_PASSWORD', 'MyOwnPassword'); // ...和密码

This is only an example password, of course! :) 当然,这只是一个密码的例子! :)

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 'localhost'.

密码行下面的另一个行,确定了你的数据库的主机。你可能99%都更改这一行,除非你的网络主机要求你更改。换句话说,你可能将这一行保留为默认的参数值'localhost'

If your database host is different than 'localhost', move down to the next line:

如果你的数据库主机与'localhost'不同,你可以转移到下一行:

define('DB_HOST', 'localhost');     // 99% chance you won't need to change this value

定义('DB_HOST', 'localhost'); //你可能99%都不会更改这个参数值

Delete localhost and enter in your database host as directed by your web host:

删除localhost并且输入你的网络主机控制的数据库主机:

define('DB_HOST', 'mysql34.myhostserver');     // 99% chance you won't need to change this value

删除('DB_HOST', 'mysql34.myhostserver'); //你可能99%都不会更改这个参数值

Of course, the mysql34.myhostserver will be different for you.

当然,mysql34.myhostserver可能对你来说,有所不同。

Possible DB_HOST values

可能的DB_HOST 参数值

Some possible DB_HOST values for hosting companies: 主机公司的一些可能的DB_HOST参数值:

  • 1and1 - something similar to db12345678
  • AN Hosting - localhost
  • BlueHost - localhost
  • DreamHost - (the database hostname you created; probably a subdomain like db.example.com)
  • GoDaddy - something similar to h41mysql52.secureserver.net
  • HostGator - localhost
  • HostICan - localhost
  • LaughingSquid - localhost
  • one.com - localhost
  • pair Networks - something similar to dbnnnx.pair.com
  • Yahoo - mysql
  • Hosts with cPanel - localhost
  • Hosts with Plesk - localhost






  • 1and1 – 与 db12345678相似
  • AN Hosting - localhost
  • BlueHost - localhost
  • DreamHost - (你创建的数据库主机名; 可能是个子域,像db.example.com)
  • GoDaddy – 与h41mysql52.secureserver.net相似
  • HostGator - localhost
  • HostICan - localhost
  • LaughingSquid - localhost
  • one.com - localhost
  • pair Networks – 与dbnnnx.pair.com相似
  • Yahoo - mysql
  • cPanel主机 - localhost
  • Plesk 主机- localhost

Mysql Alternate Port

Mysql另一个端口

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

定义('DB_HOST', 'mysql34.myhostserver:3307'); // 你可能99%都不需要更改这个参数值

You'll need to change 3307 to reflect what your host provides you as the alternate port number.

你需要更改3307,反映你的主机向你提供的另一个端口数字。

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. 2.6版本拥有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 the secret key generator.

你不需要记住这些keys,因此你可以将这些keys设置地长而复杂。设置这些keys或者使用the secret key generator

Example: 例如:

 define('AUTH_KEY', ':dr+%/5V4sAUG-gg%aS*v;&xGhd%{YKC^Z7KKGh j>k[.Nf$y7iGKdJ3c*[Kr5Bg');
 define('SECURE_AUTH_KEY', 'TufWOuA _.t>#+hA?^|3RfGTm>@*+S=8\"\'+\"}]<m#+}V)p:Qi?jXLq,<h\\`39m_(');
 define('LOGGED_IN_KEY', 'S~AACm4h1;T^\"qW3_8Zv!Ji=y|)~5i63JI |Al[(<YS<2V^$T])=8Xh2a:b:}U_E');
 define('AUTH_KEY', ':dr+%/5V4sAUG-gg%aS*v;&xGhd%{YKC^Z7KKGh j>k[.Nf$y7iGKdJ3c*[Kr5Bg');
 define('SECURE_AUTH_KEY', 'TufWOuA _.t>#+hA?^|3RfGTm>@*+S=8\"\'+\"}]<m#+}V)p:Qi?jXLq,<h\\`39m_(');
 define('LOGGED_IN_KEY', 'S~AACm4h1;T^\"qW3_8Zv!Ji=y|)~5i63JI |Al[(<YS<2V^$T])=8Xh2a:b:}U_E');





 define('AUTH_KEY', ':dr+%/5V4sAUG-gg%aS*v;&xGhd%{YKC^Z7KKGh j>k[.Nf$y7iGKdJ3c*[Kr5Bg');
 define('SECURE_AUTH_KEY', 'TufWOuA _.t>#+hA?^|3RfGTm>@*+S=8\"\'+\"}]<m#+}V)p:Qi?jXLq,<h\\`39m_(');
 define('LOGGED_IN_KEY', 'S~AACm4h1;T^\"qW3_8Zv!Ji=y|)~5i63JI |Al[(<YS<2V^$T])=8Xh2a:b:}U_E');
 define('AUTH_KEY', ':dr+%/5V4sAUG-gg%aS*v;&xGhd%{YKC^Z7KKGh j>k[.Nf$y7iGKdJ3c*[Kr5Bg');
 define('SECURE_AUTH_KEY', 'TufWOuA _.t>#+hA?^|3RfGTm>@*+S=8\"\'+\"}]<m#+}V)p:Qi?jXLq,<h\\`39m_(');
 define('LOGGED_IN_KEY', 'S~AACm4h1;T^\"qW3_8Zv!Ji=y|)~5i63JI |Al[(<YS<2V^$T])=8Xh2a:b:}U_E');

Secret Key (2.5; IMPORTANT)

Secret Key (2.5; 重要)

It is most important to change the default SECRET_KEY value to something other than 'put your unique phrase here'. Visit the WordPress secret key generation site to get a SECRET_KEY generated for you.

将默认SECRET_KEY 参数值,更改为其它值,而不是'在这里放上你的唯一的词组',这样做,很重要。 访问 WordPress secret key generation site 得到为你创建的SECRET_KEY 。


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.

2.5版本一起发行,这个新的,可选择的entry,称为SECRET_KEY,增强用户的cookes中储存的信息的保密性。Secret key是唯一的词组。

// Change SECRET_KEY to a unique phrase.  You won't have to remember it later,
// so make it long and complicated.  You can visit https://www.grc.com/passwords.htm
// 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. 


// 将 SECRET_KEY更改为唯一的密码。你不用记这个密码, 
// 因此将这个密码,设置地长而复杂。你可以访问https://www.grc.com/passwords.htm
// 选择适合你的密码,或者自己创建一个。
定义('SECRET_KEY', 'put your unique phrase here'); // 将这句话,更改为唯一的密码。

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?"

下面是wp-hackers邮件列表上,Mark Jaqith对问题所作的详细的解释," SECRET_KEY 是用来做什么的?"

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:
数据库中的hashing salt 是不可读的。"什么是 salt?" salt是给输入添加随意的内容, hash input ,使得输入内容更加难以破解。例如:

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.


在这些例子中,假定密码是"测试",但是解密高手并不知道(事实上,这真是他试图破解的内容)。我也的确掩饰了一些内容,但这确实最简单的密码。

Easy to crack: md5('test');
容易破解:md5('test');

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.


因为'test' 是字典上一个简短的单词,输出了hash的解密高手,能够轻易地使用表格 (查找字典表格) 在几秒或者几分钟内,就能够破解这个密码。

Harder to crack: md5('test' . $known_salt);
难以破解:md5('test' . $known_salt);

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.


在这个例子中,解密高手需要创建一个新的rainbow表格,将$known_salt参数值添加到这个表格的 hashes。 这样,解密的速度会降低。.

Even harder to crack: md5('test' . $unknown_salt);
更加难以破解:md5('test' . $unknown_salt);

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.


在这个例子中,解密高手不知道salt。而且因为好的salt是非常随意的组合,像"888a7da62429ba6ad3cb3c76a09641fc" – 解密高手的表格帮不了他们。他们只有"强迫" 自己尝试所有可能的组合。这种尝试很费功夫。先前可能几分钟就破解了密码,现在可能需要花几年的时间。

Database character set

数据库字符集

As of WordPress Version 2.2, DB_CHARSET was made available to allow designation of the database character set (e.g. tis620 for TIS620 Thai) to be used when defining the MySQL database tables. The default value of utf8 (Unicode 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.

从 WordPress 2.2版本开始, DB_CHARSET 就可以用来指定数据库字符集 (例如 tis620代表TIS620 Thai) ,定义MySQL数据库表格时,会使用这些字符集。 utf8 (Unicode UTF-8) 的默认参数值,再没有慎重考虑输出结果之前,不应该更改。请注意 UTF-8 支持许多欧洲语言,因此将DB_CHARSET保留在utf8 并且为你的语言,使用适当的[[WordPress:#Database collation|DB COLLATE]] 参数值。


  • 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 Character Sets and Collations That MySQL Supports for the valid values for DB_CHARSET.
  • 提醒刚刚开始安装的那些人:对于大多数欧洲语言,包括英语,通过不需要更改DB_CHARSET的默认参数值。如果你的博客需要不同的字符集,请阅读Character Sets and Collations That MySQL Supports得到DB_CHARSET的有效的参数值。
  • Warning for those performing upgrades: If DB_CHARSET and DB_COLLATE 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 WordPress:Converting Database Character Sets. Adding DB_CHARSET and DB_COLLATE to the wp-config.php file, for an existing blog, can cause problems — as Ryan Boren says, "your queries will go boom!"
  • 提醒那些将要升级的人: 如果你的文件wp-config.php 中不存在DB_CHARSET 和DB_COLLATE,不要向你的 DO NOT add either definition to your wp-config.php 文件添加任何定义,除非你阅读并且了解转变数据库字符集。为当前的博客的 wp-config.php文件,添加DB_CHARSET和 DB_COLLATE ,会产生问题 — 就如Ryan Boren所说的, "你的查询会 go boom!"


This example shows utf8 which is considered the WordPress default value:

这个例子,显示了考虑WordPress默认参数值的utf8:

   define('DB_CHARSET', 'utf8');
   define('DB_CHARSET', 'utf8');

Database collation

数据库整理

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 (i.e. DB_CHARSET). Set DB_COLLATE to one of the UTF-8 values defined in Unicode character sets (utf8 section) for most Western European languages.

从WordPress2.2版本开始,可以使用DB_COLLATE整理数据库(例如,安排字符集的顺序)。在大多数情况下,这个参数值应该保留为空白的(零),这样根据数据库字符集(例如,DB_CHARSET),MySQL会自动地分配整理数据库。将DB_COLLATE设置为统一字符集 (utf8 部分)中定义的UTF-8参数值中的一个,用户大多数西欧语言。

  • 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.
  • 提醒那些刚刚开始安装的人:通常不需要更改DB_COLLATE的默认参数值。将参数值保留为空白(零),创建数据库表格的时候,MySQL能够自动分配整理数据库。
  • Warning for those performing upgrades: 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 WordPress:Converting Database Character Sets. Adding DB_COLLATE and DB_CHARSET to the wp-config.php file, for an existing blog, can cause problems — as Ryan Boren says, "your queries will go boom!"
  • 提醒那些开始升级的人:如果你的wp-config.php文件中不存在DB_COLLATE 和DB_CHARSET ,不要向你的文件添加任何定义,除非你阅读并且理解了 转变数据库字符集。 为当前的博客, 向wp-config.php 文件添加DB_COLLATE and DB_CHARSET ,可能导致问题—就如 Ryan Boren所说的,"你的查询将会 go boom!"




This example is of the WordPress default DB_COLLATE value: 这个例子是关于WordPress默认DB_COLLATE参数值:

   define('DB_COLLATE', ); 

define('DB_COLLATE', );

  • Example if UTF-8 Unicode Turkish collation is needed (DB_CHARSET should be utf8):
  • 例子,如果需要UTF-8 Unicode Turkish collation(DB_CHARSET应该是utf8):
   define('DB_COLLATE', 'utf8_turkish_ci'); 
定义('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 installing multiple WordPress blogs in the same database.

$table_prefix是放在你的数据库表格开始部分的参数值。如果你想使用另一个数据库前缀,而不是wp_ ,你可以更改这个参数值。一般来说,如果你在同一个数据库中安装多个WordPress博客,这个参数值,就会更改。

Advanced Options

高级选项

WordPress address (URL)

WordPress 地址 (URL)

Another new wp-config.php option, added as of WordPress 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 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.

另一个新的wp-config.php选项,在 WordPress 2.2版本时,添加的,是 WP_SITEURL。 这个选项可以定义WordPress地址(URL)。定义的参数值是WordPress核心文件的地址。这个地址也应该包括 http:// 部分。地址的结尾不要加上斜线 "/" 。 在wp-config.php中设置这个参数值,废除 wp_options 表格siteurl 的参数值,并且在管理 > 设置 > 面板中,冻结WordPress地址(URL)栏。虽然不会更改数据库参数值,如果wp-config中没有移除这一行, url 将会返回到旧的数据库的参数值。

If you have installed WordPress into a directory called "wordpress" in a domain name called "example.com", define WP_SITEURL as this example does:

如果你已经在称为"example.com"的域名上,称为"wordpress"的目录上,安装了WordPress,如这个例子那样,定义WP_SITEURL:

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

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

Blog address (URL)

博客地址 (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. Also, do not put a slash "/" at the end.

WP_HOME是WordPress2.2版本中添加的另一个wp-config.php选项。与WP_SITEURL相似,WP_HOME覆盖了wp_options 表格中,home的参数值,但是并没有永久性地更改home的参数值。home是个地址,你希望人们再次输入他们的浏览器,访问你的WordPress博客。home应该包含http://部分,但是结尾不能有斜线"/"。

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

定义('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.

如果你正使用赋予WordPress自己目录中的方法,那么你可以安装下面例子的做法。记住,如果你使用这样的设置,你在网络根目录上,也会放置index.php

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

Moving wp-content

移动 wp-content

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

2.6版本开始,你可以将承载你的主题,插件,更新内容的wp-content,从WordPress应用软件目录中移除。

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

WP_CONTENT_DIR设置为这个目录的完整本地路径(结尾没有斜线),例如

 define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' );
 定义( '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.

WP_CONTENT_URL设置为这个目录的完整URI(结尾没有斜线),例如

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

Debug

调试

   define('WP_DEBUG', true);
   define('WP_DEBUG', false);

定义('WP_DEBUG', true);

   定义('WP_DEBUG', false);

The WP_DEBUG option, added in WordPress Version 2.3.1, controls the display of some errors and warnings. If this setting is absent from wp-config.php, then the value is assumed to be false. Note that the true and false values are not set in apostrophes (').

WP_DEBUG选项,是WordPress2.3.1版本添加的,控制错误和警告的显示。如果wp-config.php中没有这个设置,那么参数值应该是错误的。注意truefalse,没有设置在呼语符号内(')。

In Wordpress versions since 2.3.2, database errors are printed only if WP_DEBUG is set to true. In earlier versions, database errors were always printed. (Database errors are handled by the wbdb class and are not affected by PHP's error settings.)

自从WordPress2.3.2版本,只有WP_DEBUG 设置为 true,才会打印数据库错误。在之前更早的版本中,数据库错误通常会打印。(数据库错误通常是由wbdb class处理的,而且不会受PHP的错误设置的影响。)

In WordPress version 2.5, setting WP_DEBUG to true also raises the error reporting level to E_ALL and activates warnings when deprecated functions or files are used; otherwise, WordPress sets the error reporting level to E_ALL ^ E_NOTICE ^ E_USER_NOTICE.

在WordPress2.5版本中,将WP_DEBUG设置为true,同时将错误报告级别提高为E_ALL,并且在使用deprecated函数或者文件的时候,激活警告;否则,WordPress将错误报告级别设置为E_ALL ^ E_NOTICE ^ E_USER_NOTICE

Increasing memory allocated to PHP

增加分派给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".

WP_MEMORY_LIMIT选项也是与2.5版本一起发行的,这个选项能够使你规定PHP可以消耗的最大的内存。当你收到消息" xxxxxx字节 可以使用的内存大小已经消耗"时,你可能需要用到这个选项。

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,而不是其它的应用软件,增加了PHP内存。默认情况下,WordPress会尝试将PHP的内存增加到32MB(wp-settings.php的开头有代码),因此wp-config.php中的设置,应该反映了比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.

请注意,如果你的主机不允许增加有限的PHP内存,这个设置可能不能够运行—这样的话,可以联系你的主机来增加PHP内存。同时,要注意,许多主机都将PHP内存设置为8MB。

Increase PHP Memory to 64MB

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

将PHP内存增加到64MB

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

Increase PHP Memory to 96MB

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

将PHP内存增加到96MB

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

Cache

告诉缓存

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

WP_CACHE设置,如果是正确的,执行wp-settings.php时,包含了wp-content/advanced-cache.php脚本。

define('WP_CACHE', true); 
定义('WP_CACHE', true); 

Custom User and Usermeta Tables

自定义用户和 Usermeta 表格

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_TABLECUSTOM_USER_META_TABLE是用来指定WordPress通常使用的用户和usermeta表格,被取代了,这些参数值。

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

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定义了语言翻译(.mo)文件的名称。LANGDIR定义了WPLANG .mo文件所处的目录。如果没有定义LANGDIR,WordPress首先查找wp-content/languages,然后查找wp-includes/languages上WPLANG文件定义的.mo。

define('WPLANG', 'de_DE');
define('LANGDIR', 'mylanguagedirectory');
定义('WPLANG', 'de_DE');
定义('LANGDIR', 'mylanguagedirectory');

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.

SAVEQUERIES 定义将数据库查询保存到一个数组中,可以显示这个数组来帮助分析这些查询。信息保存了每个查询,那个函数调用了查询,以及这个查询执行需要多长时间。

First, put this in wp-config.php:

首先,将这个查询放在wp-config.php:

define('SAVEQUERIES', true);
定义('SAVEQUERIES', true);

Then in the footer of your theme put this: 然后在你的主题的页脚,放上:

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


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

The code above uses the switch_themes capability so only visitors with that capability will see the query results.

上述的代码使用了switch_themes权限,因此只有拥有这个权限的用户,才能够看到这个查询结果。

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!

确定检查了你在上面输入的参数值前后的空格,而且不要删除单引号!

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.

在你保存文件前,一定要仔细检查,确认你没有以外地删除参数值周围的单引号。确定文件中关闭的PHP标签后没有任何内容。文件中的最后一项,应该是?>,除此之外,没有其它任何内容,没有空格。

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,并且将文件保存到你安装的WordPress的根目录上。将文件上传到你的网络服务器,你开始安装WordPress了!

wp-config.php with Multiple Blogs

多个博客的 wp-config.php

Multiple WordPress blogs require special handling of their configuration files. Check WordPress:Installing Multiple Blogs for more information.

多个WordPress博客需要特别处理,博客配置文件。更多的信息,请查看安装多个博客

留言