Wordpress

来自 Arch Linux 中文维基

本文内容或本节内容已经过期。

原因: 请提供模板的第一个位置参数以概括原因。 (在Talk:Wordpress讨论)

这篇文章或章节的翻译不反映原文。

原因:Last updated in 2017 (473190), out of sync with English page(在 Talk:Wordpress# 中讨论)

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#PHP[损坏的链接:无效的章节]LAMP#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

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

数据库名称是

注意: 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.

使用管理面板安装主题[编辑 | 编辑源代码]

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.

手动安装主题[编辑 | 编辑源代码]

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.

升级[编辑 | 编辑源代码]

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.

故障排除[编辑 | 编辑源代码]

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[编辑 | 编辑源代码]