zh-cn:安装WordPress
Languages:
English •
日本語 •
ไทย •
Русский •
中文(简体) •
(Add your language)
WordPress以它的易于安装而出名。在大多数情况下,安装WordPress是一个很简单的事情,并且花不到5分钟就可以搞定。现在很多web主机都提供自动安装WordPress的工具(如Fantastico)。但是如果你想亲自安装 WordPress,下面的教程将会是很有帮助的,适用于WordPress 2.7及以后的版本,升级就更容易了。
不管你是想用著名的5分钟安装,还是需要更多详细的安装指导,以下的安装指导将会帮助你完成安装。
开始安装WordPress之前你需要知道的东西
开始安装之前,还有一些事情你需要有和需要做的。你需要能够访问你的网站和它的目录和软件来开始安装。 包括:
安裝WordPress你必須做的事情
开始你的安装:
- 确保你的网站主机满足运行WordPress的最低要求.
- 下载最新版的WordPress.
- 将下载来的文件解压至你的硬盘.
- 准备好你的 安全密钥
- 打印本文,以便你安装遇到麻烦时参阅.
著名的5分安装
这个是快速安装的操作指南, 对于那些已经熟悉这些安装的. 更多 detailed instructions 下面.
- 下载并解压缩WordPress程序安装包, 如果你还没的话.
- 在你的网页服务器上为WordPress创建一个数据库, 并且也创建一个MySQL 拥有所有权限可以进入和修改的用户.
- 重命名 wp-config-sample.php 文件为 wp-config.php.
- 用你最喜欢的 文本编辑器 打开 wp-config.php ,填上你的数据库信息。
- 把WordPress文件夹放在你服务器上想要放的地方:
- 如果你想把通过顶级域名来访问你的WordPress博客 (例如 http://example.com/),移动或上传所有解压后的WordPress文件夹里面的文件(但不包括WordPress文件夹本身) 到你服务器的根目录下.
- 如果你想通过子域名来访问你的博客(例如 http://example.com/blog/), 将wordpress 重命名为你想要的子目录名称, 接着上传至你的网站服务器。 例如,你想让WordPress 安装在子目录"blog"中,你就应该将"wordpress"这个文件夹重命名为"blog",接着上传至你的网站服务器的根目录中。
提示: 如果你的FTP传送得太慢,请参阅怎样避免FTPing: 步骤1:下载与解压缩.
- 在你喜欢的浏览器中访问wp-admin/install.php 以便启动安装程序.
- 如果你在根目录下安装WordPress,,你应该访问: http://example.com/wp-admin/install.php
- 如果你将WordPress安装在子目录blog下,你应该访问: http://example.com/blog/wp-admin/install.php
就这样了!WordPress应该可以安装了。
详细的安装说明
步骤1:下载与解压缩
从此处下载WordPress压缩包并解压缩 http://wordpress.org/download/
- 如果你想将WordPress上传至一个远程服务器,先下载WordPress压缩包至你的电脑,接着解压缩
- 如果你使用shell来访问你的服务器,而且你可以很轻松地使用console工具,你可以使用wget (或者 lynx 再或者其他的console命令)来直接下载WordPress至你的web server,这样就可以避免使用FTPing(该方法适用于Linux系统):
- wget http://wordpress.org/latest.tar.gz
- 接着使用一下命令解压缩:
tar -xzvf latest.tar.gz
这样WordPress压缩包将会解压缩至文件夹wordpress ,这个文件夹与你下载的latest.tar.gz压缩包处于同一个目录下.
Step 2: Create the Database and a User
If you are using a hosting provider, you may already have a WordPress database set up for you, or there may be an automated setup solution to do so. Check your hosting provider's support pages or your control panel for clues about whether or not you'll need to create one manually.
If you determine that you'll need to create one manually, follow the instructions for accessing phpMyAdmin on various servers, or follow the instructions for Using cPanel or Using phpMyAdmin below.
If you are installing WordPress on your own web server, follow the Using phpMyAdmin or Using the MySQL Client instructions below to create your WordPress username and database.
If you have only one database and it is already in use, you can install WordPress in it - just make sure to have a distinctive prefix for your tables, to avoid over-writing any existing database table.
Using cPanel
Main article: Using cPanel
If your hosting provider uses cPanel, you may follow these instructions to create your WordPress username and database.
- Log in to your cPanel.
- Click MySQL Databases.
- If a user relating to WordPress does not already exist under the Users section, create one:
- Chose a username for WordPress ('wordpress' is good) and enter it in the UserName field.
- Choose a difficult-to-guess password (ideally containing a combination of upper- and lower-case letters, numbers, and symbols), and enter it in the Password field.
- Write down the username and password you chose.
- Click Add User.
- If a database relating to WordPress does not already exist under the Databases section, create one:
- Choose a name for your WordPress database ('wordpress' or 'blog' are good), enter it in the Db field, and click Add Db.
- Under Databases, select your WordPress username from the User dropdown, then select your WordPress database from the Db dropdown. Make sure All is checked under Privileges, then click Add User to Db.
- When you return to the main MySQL Account Maintenance screen, cPanel will list information about the database you just created. You should see the username you just added to the database (with ALL PRIVILEGES), as well as a few sample Connection Strings for you to use in Perl or PHP scripts to connect to the database. The PHP code will have the following format:
$dbh = mysql_connect("hostname", "username", "<PASSWORD HERE>") or die ("message");
mysql_select_db("databasename");
- Write down the values of hostname, username, databasename, and the password you chose. (Note that hostname will usually be localhost.)
Using phpMyAdmin
If your web server has phpMyAdmin installed, you may follow these instructions to create your WordPress username and database.
Note: These instructions are written for phpMyAdmin 2.6.0; the phpMyAdmin user interface can vary slightly between versions.
- If a database relating to WordPress does not already exist in the Database dropdown on the left, create one:
- Choose a name for your WordPress database ('wordpress' or 'blog' are good), enter it in the Create new database field, and click Create.
- Click the Home icon in the upper left to return to the main page, then click Privileges. If a user relating to WordPress does not already exist in the list of users, create one:
- Click Add a new User.
- Chose a username for WordPress ('wordpress' is good) and enter it in the User name field. (Be sure Use text field: is selected from the dropdown.)
- Choose a difficult-to-guess password (ideally containing a combination of upper- and lower-case letters, numbers, and symbols), and enter it in the Password field. (Be sure Use text field: is selected from the dropdown.) Re-enter the password in the Re-type field.
- Write down the username and password you chose.
- Leave all options under Global privileges at their defaults.
- Click Go.
- Return to the Privileges screen and click the Check privileges icon on the user you've just created for WordPress. In the Database-specific privileges section, select the database you've just created for WordPress under the Add privileges to the following database dropdown. The page will refresh with privileges for that database. Click Check All to select all privileges, and click Go.
- On the resulting page, make note of the host name listed after Server: at the top of the page. (This will usually be localhost.)
Using the MySQL Client
You can create MySQL users and databases quickly and easily by running mysql from the shell. The syntax is shown below and the dollar sign is the command prompt:
$ mysql -u adminusername -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname"
-> IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> EXIT
Bye
$
The example shows:
- that root is also the adminusername. It is a safer practice to choose a so-called "mortal" account as your mysql admin, so that you are not entering the command "mysql" as the root user on your system. (Any time you can avoid doing work as root you decrease your chance of being exploited). The name you use depends on the name you assigned as the database administrator using mysqladmin.
- wordpress or blog are good values for databasename.
- wordpress is a good value for wordpressusername but you should realize that, since it is used here, the entire world will know it too.
- hostname will usually be localhost. If you don't know what this value should be, check with your system administrator if you are not the admin for your Wordpress host. If you are the system admin, consider using a non-root account to administer your database.
- password should be a difficult-to-guess password, ideally containing a combination of upper- and lower-case letters, numbers, and symbols. One good way of avoiding the use of a word found in a dictionary, uses the first letter of each word in a phrase that you find easy to remember.
If you need to write these values somewhere, avoid writing them in the system that contains the things protected by them. You need to remember the value used for databasename, wordpressusername, hostname, and password. Of course, since they are already in ) or will be, shortly) your wp-config.php file, there is no need to put them somewhere else, too.
Using Plesk
See: Plesk 7 at tamba2.org
步骤3:设置wp-config.php
You can either create and edit the wp-config.php file yourself, or you can skip this step and let WordPress try to do this itself when you run the installation script (step 5) (you'll still need to tell WordPress your database information).
(For more extensive details, and step by step instructions for creating the configuration file and your secret key for password security, please see Editing wp-config.php.)
Return to where you extracted the WordPress package in Step 1, rename the file wp-config-sample.php to wp-config.php, and open it in a text editor.
Enter your database information under the section labeled
// ** MySQL settings - You can get this info from your web host ** //
- DB_NAME
- The name of the database you created for WordPress in Step 2 .
- DB_USER
- The username you created for WordPress in Step 2.
- DB_PASSWORD
- The password you chose for the WordPress username in Step 2.
- DB_HOST
- The hostname you determined in Step 2 (usually localhost, but not always; see some possible DB_HOST values).
- DB_CHARSET
- The database character set, normally should not be changed (see Editing wp-config.php).
- DB_COLLATE
- The database collation should normally be left blank (see Editing wp-config.php).
Enter your secret key values under the section labeled
* Authentication Unique Keys.
Save the wp-config.php file.
For information on enabling SSL in WordPress 2.6, see SSL and Cookies in WordPress 2.6.
Step 4: Upload the files
Now you will need to decide where on your web site you'd like your blog to appear:
- In the root directory of your web site. (For example, http://example.com/)
- In a subdirectory of your web site. (For example, http://example.com/blog/)
Note: The location of your root web directory in the filesystem on your web server will vary across hosting providers and operating systems. Check with your hosting provider or system administrator if you do not know where this is.
In the Root Directory
- If you need to upload your files to your web server, use your favorite FTP client to upload all the contents of the wordpress directory (but not the directory itself) into the root directory of your web site.
- If your files are already on your web server, and you are using shell access to install WordPress, move all of the contents of the wordpress directory (but not the directory itself) into the root directory of your web site.
In a Subdirectory
- If you need to upload your files to your web server, rename the wordpress directory to your desired name, then use your favorite FTP client to upload the directory to your desired location within the root directory of your web site.
- If your files are already on your web server, and you are using shell access to install WordPress, move the wordpress directory to your desired location within the root directory of your web site, and rename the directory to your desired name.
Step 5: Run the Install Script
Point your favorite web browser to start the installation script.
- If you placed the WordPress files in the root directory, you should visit: http://example.com/wp-admin/install.php
- If you placed the WordPress files in a subdirectory called blog, for example, you should visit: http://example.com/blog/wp-admin/install.php
Setup configuration file
If WordPress can't find the wp-config.php file, it will tell you and offer to try to create and edit the file itself. (You can do also do this directly by loading wp-admin/setup-config.php in your web browser.) WordPress will ask you the database details and write them to a new wp-config.php file. If this works, you can go ahead with the installation; otherwise, go back and create, edit, and upload the wp-config.php file yourself (step 3).
Finishing installation
The following screenshots show how the installation progresses. Notice in the screen, Entering the details, you enter your Weblog title and your e-mail address. Also displayed is a check-box asking if you would like your blog to appear in search engines like Google and Technorati. Leave the box checked if you would like your blog to be visible to everyone, including search engines, and uncheck the box if you want to block search engines, but allow normal visitors. Note all this information can be changed later in your Administration Panels.
Version 2.7
WordPress Version 2.7, Entering details
WordPress Version 2.7, All done!
Install Script Troubleshooting
- If you get an error about the database when you run the install script:
- Go back to Step 2 and Step 3, and be sure you got all the correct database information and that it was entered correctly into wp-config.php.
- Be sure you granted your WordPress user permission to access your WordPress database in Step 3.
- Be sure the database server is running.
常见的安装问题
The following are some of the most common installation problems. For more information and troubleshooting for problems with your WordPress installation, check out FAQ Installation and FAQ Troubleshooting.
I see lots of Headers already sent errors. How do I fix this?
You probably introduced a syntax error in editing wp-config.php.
- Download wp-config.php (if you don't have shell access).
- Open it in your favorite text editor.
- Check that the first line contains nothing but <?php, and that there is no text before it (not even whitespace).
- Check that the last line contains nothing but ?>, and that there is no text after it (not even whitespace).
- If your text editor saves as Unicode, make sure it adds no byte order mark (BOM). Most Unicode-enabled text editors do not inform the user whether it adds a BOM to files; if so, try using a different text editor.
- Save the file, upload it again if necessary, and reload the page in your browser.
My page comes out gibberish. When I look at the source I see a lot of "<?php ?>" tags.
If the <?php ?> tags are being sent to the browser, it means your PHP is not working properly. All PHP code is supposed to be executed before the server sends the resulting HTML to your web browser. (That's why it's called a preprocessor.) Make sure your web server meets the requirements to run WordPress, that PHP is installed and configured properly, or contact your hosting provider or system administrator for assistance.
I keep getting an Error connecting to database message but I'm sure my configuration is correct.
Try resetting your MySQL password manually. If you have access to MySQL via shell, try issuing:
SET PASSWORD FOR 'wordpressusername'@'hostname' = OLD_PASSWORD('password');
If you are using a version of MySQL prior to 4.1, use PASSWORD instead of OLD_PASSWORD. If you do not have shell access, you should be able to simply enter the above into an SQL query in phpMyAdmin. Failing that, you may need to use your host's control panel to reset the password for your database user.
My image/MP3 uploads aren't working.
If you use the Rich Text Editor on a blog that's installed in a subdirectory, and drag a newly uploaded image into the editor field, the image may vanish a couple seconds later. This is due to a problem with TinyMCE (the rich text editor) not getting enough information during the drag operation to construct the path to the image or other file correctly. The solution is to NOT drag uploaded images into the editor. Instead, click and hold on the image and select "Send to Editor."
Installation Instructions in Other Languages
For installation instructions in other languages, see WordPress in Your Language.
安装多个博客
Detailed information about Installing Multiple Blogs is available.
Installing WordPress on your own Computer
Manual Installation Instructions
If you have a sufficiently powerful home computer and a sufficiently fast broadband connection, you may want to avoid certain hosting charges by using your own computer as a server. The following tutorials will show you how to setup a server environment and install WordPress on your home computer.
Using a Software Appliance
Manual installation of WordPress on a local server can be painful and time consuming, especially for users lacking technical proficiency. Many users may find that using a pre-integrated software appliance is an easier way to get up and running with WordPress, especially in combination with virtual machine software (e.g., VMWare, VirtualBox, Xen HVM, KVM).
A software appliance allows users to altogether skip manual installation of WordPress and its dependencies, and instead deploy a self-contained system that requires little to no setup, in just a couple of minutes.
- TurnKey WordPress Appliance: An open source WordPress appliance based on Ubuntu, which features a small footprint, automatic security updates, SSL support and a Web administration interface.
Resources