Difference between revisions of "Wordpress (简体中文)"

From ArchWiki
Jump to: navigation, search
(待续)
(233)
Line 18: Line 18:
 
=== 使用pacman安装 ===
 
=== 使用pacman安装 ===
  
 +
建议手动安装!!!
 
[[Install]] the {{pkg|wordpress}} package.
 
[[Install]] the {{pkg|wordpress}} package.
  
Line 60: Line 61:
 
  修改第一行的{{ic|/wordpress}} 为你想要的。例如, {{ic|/myblog}} 将要求你导航到 {{ic|http://hostname/myblog}} 来访问你的WordPress.
 
  修改第一行的{{ic|/wordpress}} 为你想要的。例如, {{ic|/myblog}} 将要求你导航到 {{ic|http://hostname/myblog}} 来访问你的WordPress.
  
Also change the paths to your WordPress install folder in case you did a manual install. Do not forget to append the parent directory to the {{ic|php_admin_value}} variable as well as shown below.
+
如果你是手动安装的话,还需要修改你的WordPress安装文件夹的路径。 不要忘记将父目录添加到{{ic|php_admin_value}}如下所示。
  
 
{{hc|# /etc/httpd/conf/extra/httpd-wordpress.conf|
 
{{hc|# /etc/httpd/conf/extra/httpd-wordpress.conf|
Line 70: Line 71:
 
</Directory>}}
 
</Directory>}}
  
Next edit the [[Apache]] configuration file and add the following:
+
然后编辑[[Apache]]配置文件,添加以下行:
  
 
{{hc|# /etc/httpd/conf/httpd.conf|
 
{{hc|# /etc/httpd/conf/httpd.conf|
Line 76: Line 77:
 
}}
 
}}
  
Now restart {{ic|httpd.service}} (Apache) using [[systemd#Using units|systemd]].
+
现在使用[[systemd#Using units|systemd]]重启{{ic|httpd.service}} (Apache)
  
=== Configure MySQL ===
+
=== 配置MySQL ===
  
MySQL can be configured using a plethora of tools, but the most common are the command-line or [http://www.phpmyadmin.net/home_page/index.php phpMyAdmin].
+
MySQL 可以使用多种工具进行配置,但是最常用的是使用命令行和[http://www.phpmyadmin.net/home_page/index.php phpMyAdmin].
  
{{Tip|Make sure MariaDB is installed and configured correctly. At a minimum, follow the [[MySQL#Installation|installation instructions]] for Arch Linux.}}
+
{{提示|确保MariaDB已经安装和正确配置。至少要遵循 [[MySQL#Installation|installation instructions]] for Arch Linux.}}
  
==== Using MariaDB command-line tool ====
+
==== 使用MariaDB命令行工具====
  
First, login as root. You will be asked for your MariaDB root password:
+
首先,以root身份登录。您将被要求输入您的MariaDB root密码:
  
 
  $ mysql -u root -p
 
  $ mysql -u root -p
  
Then create a user and database:
+
然后创建一个用户和数据库
{{Note|{{ic|wordpress}} is your Database Name and {{ic|wp-user}} is your User Name. You can change them if you wish. Also replace {{ic|choose_db_password}} with your new Password for this database. You will be asked for these values along with {{ic|localhost}} in the next section.}}  
+
数据库名称是{{Note|{{ic|wordpress}},用户名是{{ic|wp-user}}。你可以修改它们为你想要的.。还可以使用您的新数据库密码替换{{ic|choose_db_password}}。你需要在下一部分{{ic|localhost}}提供这些值}}  
  
 
{{bc|MariaDB> CREATE DATABASE wordpress;
 
{{bc|MariaDB> CREATE DATABASE wordpress;
Line 98: Line 99:
 
MariaDB> EXIT}}
 
MariaDB> EXIT}}
  
See WordPress.org [https://codex.wordpress.org/Installing_WordPress#Using_the_MySQL_Client official instructions] for details.
+
访问WordPress.org [https://codex.wordpress.org/Installing_WordPress#Using_the_MySQL_Client official instructions]获取更多细节.
  
==== Using phpMyAdmin ====
+
==== 使用phpMyAdmin ====
  
See [[phpMyAdmin]] to install and configure phpMyAdmin.
+
访问[[phpMyAdmin]]来安装和配置phpMyAdmin.
  
In your web browser, navigate to your phpMyAdmin host and perform the following
+
在你的浏览器中,登录到你的phpMyAdmin并执行以下操作:
steps:
 
  
# Login to phpMyAdmin.
+
# 登录phpMyAdmin。
# Click "user" and then click "Add user".
+
# 点击"user"然后点击"Add user"
# Give the pop up window a name and a password.
+
# 在弹出窗口输入名字和密码。
# Select "Create database with same name and grant all privileges".
+
# 选择"Create database with same name and grant all privileges"给予全部权限。
# Click the "Add user" button to create the user.
+
# 点击"Add user"按钮来创建一个用户。
  
== WordPress Installation ==
+
== WordPress安装 ==
  
Once you have spent a couple of hours setting up your http server, php, and mysql, it is finally time to let WordPress have its five minutes and install itself. So let us begin.
 
  
The WordPress installation procedure will use the URL in the address field of your web browser as the default website URL. If you have navigated to http://localhost/wordpress, your website will be accessible from your local network, but it will be broken in appearance and function.
+
一旦你花了几个小时的时间设置你的http服务器、php和mysql,这将是是最后的安装WordPress的五分钟,让我们开始吧。
  
# Navigate to {{ic|http://hostname/wordpress}}.
+
# 访问{{ic|http://hostname/wordpress}}
# Click the "Create a Configuration File" button.
+
# 点击"Create a Configuration File" 按钮。
# Click the "Let's go!" button.
+
# 点击"Let's go!"按钮。
# Fill in you database information created in the previous section
+
# 填写上一节中创建的数据库信息。
# Click "Submit".
+
# 点击"Submit"
  
If you installed WordPress from the Official repository, then this setup procedure will not have the correct permissions to create the wp-config.php file used by WordPress. You will have to do this step yourself as root using information WordPress will provide.
+
假如你使用的是pacman安装的WordPress, 那么这个安装过程将无法创建WordPress使用的wp-config.php文件的正确权限。您将不得不使用WordPress将提供的信息以root身份执行此步骤。
  
A page will appear saying WordPress can not write the wp-config.php file. Copy the text in the edit box and open {{ic|/usr/share/webapps/wordpress/wp-config.php}} as root in your text editor. Paste the copied text into the editor and save the file.
+
将出现一个页面,说WordPress无法写入wp-config.php文件。复制编辑框中的文本,并在文本编辑器中以root身份打开{{ic|/usr/share/webapps/wordpress/wp-config.php}}。 将复制的文本粘贴中并保存文件。
  
After that, you will have to change permissions of the /usr/share/webapps/wordpress/ and all the files inside it to user {{ic|http}} and group {{ic|http}} by using chown so that the webserver can access it.
+
之后,您必须使用chown将/usr/share/webapps/wordpress/及其中的所有文件的权限修改为 用户为{{ic|http}} 组为{{ic|http}},以便网络服务器可以访问它。
  
Finally, Click "Run the install" and WordPress will populate the database with your information. Once complete, you will be shown "Success!" page. Click the login button to finish your installation.
+
最后,点击"Run the install" ,WordPress将使用您的信息填充数据库。一旦完成,页面将显示"Success!"。点击login按钮结束你的安装。
  
Now would be a good time to access your website from all your devices to be sure your WordPress installation is setup correctly.
+
现在是从所有设备访问您的网站的好时机,确保您的WordPress安装设置正确。
  
== Usage ==
+
== 使用 ==
  
=== Installing a theme ===
+
=== 安装一个主题 ===
  
==== Finding new themes ====
+
==== 寻找新的主题 ====
  
There are tens of thousands of themes available for WordPress. Searching on google for a good theme can be like wading through a river filled with trash. Good places for looking for themes include:
+
WordPress有数以万计的可用主题。在谷歌搜索一个好的主题就好像通过一个充满垃圾的河流。寻找主题的好地方包括:
  
 
* [https://wordpress.org/themes/ Official WordPress theme website]
 
* [https://wordpress.org/themes/ Official WordPress theme website]
Line 148: Line 147:
 
* [http://www.woothemes.com/ Woo Themes]
 
* [http://www.woothemes.com/ Woo Themes]
  
{{Tip|One can use WordPress' admin interface to install plugins and themes. To do this, make the user that serves WordPress the [[File_permissions_and_attributes#Changing_permissions|owner]] of your WordPress directory. For [[Apache_HTTP_Server#Advanced_options|Apache]] this user is normally http.}}
+
{{提示|可以使用WordPress的管理界面来安装插件和主题。为此, make the user that serves WordPress the [[File_permissions_and_attributes#Changing_permissions|owner]] of your WordPress directory. For [[Apache_HTTP_Server#Advanced_options|Apache]] this user is normally http.}}
  
 
==== Install using the admin panel ====
 
==== Install using the admin panel ====

Revision as of 13:39, 2 April 2017

WordPress是由Matt Mullenweg创建的免费开源内容管理系统(CMS),并于2003年首次发行。WordPress拥有庞大而充满活力的社区,提供数以万计的免费插件和主题,让用户轻松自定义WordPress的外观和功能。 WordPress是根据GPLv2授权的。

Wordpress的最大特性是易于配置与管理。搭建WordPress将使用5分钟(实际上远远不止). WordPress管理面板允许用户轻松地配置其网站的几乎每个方面,包括获取和安装插件和主题。WordPress提供方便的自动更新。

安装

WordPress需要安装和配置PHPMySQL 。 详细请查阅LAMP文档。在配置中,某些WordPress功能需要PHP extensions 可能不是默认打开。

使用pacman安装

建议手动安装!!! Install the wordpress package.

警告: 虽然使用pacman能更容易的安装和升级WordPress, 但这不是必须的。WordPress具有内置功能,用于管理更新,主题和插件。 如果你决定使用pacman安装官方仓库的,如果不配置必须的权限的话,您将无法使用WordPress管理面板安装插件和主题,或以root身份登录FTP. 无论您是否手动或以其他方式将数据添加到目录,pacman都不会从系统中卸载WordPress安装目录。

手动安装

访问wordpress.org下载WordPress的最新版本,将其解压到你的webserver目录中. 为目录提供足够的权限,允许您的FTP用户写入目录(WordPress需要使用)。

cd /srv/http/whatever
wget https://wordpress.org/latest.tar.gz
tar xvzf latest.tar.gz

配置

这里使用的配置方法假设您是在本地网络上使用WordPress。

主机配置

确保你的/etc/hosts已经正确配置. 当从本地网络访问WordPress CMS时,这将非常重要。你的/etc/hosts文件应该如下所示,

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1       lithium.kaboodle.net    localhost lithium
::1             lithium.kaboodle.net    localhost lithium
注意: 如果计划使用主机名安装WordPress,则需要使用代理服务器从移动设备访问您的WordPress安装,否则你的网站将会崩溃 #Appearance is broken (no styling).

配置apache

注意: 你将需要 Apache 已经配置运行PHPMySQL,检查 LAMP#PHPLAMP#MySQL/MariaDB 说明的部分。

你将需要为apache创建一个配置文件来找到你安装的WordPress。使用你最爱的编辑器创建以下的文件:

# /etc/httpd/conf/extra/httpd-wordpress.conf
Alias /wordpress "/usr/share/webapps/wordpress"
<Directory "/usr/share/webapps/wordpress">
	AllowOverride All
	Options FollowSymlinks
	Require all granted
</Directory>
修改第一行的/wordpress 为你想要的。例如, /myblog 将要求你导航到 http://hostname/myblog 来访问你的WordPress.

如果你是手动安装的话,还需要修改你的WordPress安装文件夹的路径。 不要忘记将父目录添加到php_admin_value如下所示。

# /etc/httpd/conf/extra/httpd-wordpress.conf
Alias /myblog "/mnt/data/srv/wordpress"
<Directory "/mnt/data/srv/wordpress">
	AllowOverride All
	Options FollowSymlinks
	Require all granted
</Directory>

然后编辑Apache配置文件,添加以下行:

# /etc/httpd/conf/httpd.conf
Include conf/extra/httpd-wordpress.conf

现在使用systemd重启httpd.service (Apache)。

配置MySQL

MySQL 可以使用多种工具进行配置,但是最常用的是使用命令行和phpMyAdmin.

提示: 确保MariaDB已经安装和正确配置。至少要遵循 installation instructions for Arch Linux.

使用MariaDB命令行工具

首先,以root身份登录。您将被要求输入您的MariaDB root密码:

$ mysql -u root -p

然后创建一个用户和数据库

数据库名称是

Note: wordpress,用户名是wp-user。你可以修改它们为你想要的.。还可以使用您的新数据库密码替换choose_db_password。你需要在下一部分localhost提供这些值
MariaDB> CREATE DATABASE wordpress;
MariaDB> GRANT ALL PRIVILEGES ON wordpress.* TO "wp-user"@"localhost" IDENTIFIED BY "choose_db_password";
MariaDB> FLUSH PRIVILEGES;
MariaDB> EXIT

访问WordPress.org official instructions获取更多细节.

使用phpMyAdmin

访问phpMyAdmin来安装和配置phpMyAdmin.

在你的浏览器中,登录到你的phpMyAdmin并执行以下操作:

  1. 登录phpMyAdmin。
  2. 点击"user"然后点击"Add user"。
  3. 在弹出窗口输入名字和密码。
  4. 选择"Create database with same name and grant all privileges"给予全部权限。
  5. 点击"Add user"按钮来创建一个用户。

WordPress安装

一旦你花了几个小时的时间设置你的http服务器、php和mysql,这将是是最后的安装WordPress的五分钟,让我们开始吧。

  1. 访问http://hostname/wordpress
  2. 点击"Create a Configuration File" 按钮。
  3. 点击"Let's go!"按钮。
  4. 填写上一节中创建的数据库信息。
  5. 点击"Submit"。

假如你使用的是pacman安装的WordPress, 那么这个安装过程将无法创建WordPress使用的wp-config.php文件的正确权限。您将不得不使用WordPress将提供的信息以root身份执行此步骤。

将出现一个页面,说WordPress无法写入wp-config.php文件。复制编辑框中的文本,并在文本编辑器中以root身份打开/usr/share/webapps/wordpress/wp-config.php。 将复制的文本粘贴中并保存文件。

之后,您必须使用chown将/usr/share/webapps/wordpress/及其中的所有文件的权限修改为 用户为http 组为http,以便网络服务器可以访问它。

最后,点击"Run the install" ,WordPress将使用您的信息填充数据库。一旦完成,页面将显示"Success!"。点击login按钮结束你的安装。

现在是从所有设备访问您的网站的好时机,确保您的WordPress安装设置正确。

使用

安装一个主题

寻找新的主题

WordPress有数以万计的可用主题。在谷歌搜索一个好的主题就好像通过一个充满垃圾的河流。寻找主题的好地方包括:

提示: 可以使用WordPress的管理界面来安装插件和主题。为此, make the user that serves WordPress the owner of your WordPress directory. For Apache this user is normally http.

Install using the admin panel

Before installing a theme using the admin panel, you will need to setup an FTP server on your WordPress host. To maintain a high level of protection, you might set up a user on your system specifically for WordPress, give it the home directory of <path to your WordPress install>/wp-content, disallow anonymous login, and allow no more users to log in than for WordPress (and obviously others as required by your setup).

Once the FTP server is setup, login to your WordPress installation and click "Appearance->Install Themes->Upload". From there select your zip file that contains your theme and click "Install Now". You will be presented with a box asking for FTP information, enter it and click "Proceed". You might need to update file ownership and rights if WordPress reports that it is unable to write to the directory. If you have been following along closely, you should now have an installed theme. Activate it if you wish.

Install manually

Download the archive and extract into the wp-content/themes folder

# Example for a theme named "MyTheme"
cd /path/to/wordpress/root/directory
cd wp-content/themes
# get the theme archive and extract
wget http://www.example.com/MyTheme.zip
unzip MyTheme.zip
# remove the archive (optional)
rm MyTheme.zip

Be sure to follow any additional instructions as provided by the theme author.

Select your new theme from the theme chooser ("Appearance->Themes")

Installing a plugin

The steps for installing a plugin are the same as they are for installing a theme. Just click the "Plugins" link in the left navigation bar and follow the steps.

Updating

Every now and then when you log into wordpress there will be a notification informing you of updates. If you have correctly installed and configured an FTP client, and have the correct filesystem permissions to write in the WordPress install path then you should be able to perform updates at the click of a button. Just follow the steps.

Alternatively, you can use SSH to update your installation with the SSH SFTP Updater Support plugin.

Troubleshooting

Appearance is broken (no styling)

Your WordPress website will appear to have no styling to it when viewing it in a web browser (desktop or mobile) that does not have its hostnames mapped to ip addresses correctly.

This occurs because you used a url with the hostname of your server, instead of an ip address, when doing the initial setup and WordPress has used this as the default website URL.

To fix this, you will either need to edit your /etc/hosts file or setup a proxy server. For an easy to setup proxy server, see Polipo, or if you want something with a little more configuration, see Squid.

Another option is changing a value in the database table of your WordPress, specifically the wp_options table. The fix is to change the siteurl option to point directly to the domain name and not "localhost".

Tips and tricks

See also