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[編輯 | 編輯原始碼]