Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tutorial / Plone Installation

Plone Installation

安裝 Plone 是使用或學習的第一步,初次體驗 Plone 最簡單的方法,是利用自動安裝檔,上手之後,就可以使用進階方式來建立開發環境,或是佈署執行環境。

安裝 Plone 的過程,需要依序準備好 Python 和 Zope 環境,幸好,藉由自動安裝檔 (Unified Installer) 的協助,彈指之間就能搞定 Plone 的安裝。

注意:Plone 安裝和管理方式,和傳統 PHP 加上 Apache 之類的運作模式不同,PHP 初學者要跳脫舊有經驗,不要侷限在 PHP 加 Apache 的 Document Root 預設想像上。

最簡化的安裝

想要快速體驗 Plone 系統,最具效益的方式,是下載自動安裝檔 (Unified Installer) 來建立系統,自動安裝檔預設是方便 Linux/BSD/Unix/MacOS 環境使用,另外也可能找得到 VirtualBox 或Windows 安裝檔。安裝之後,會產生一致的預設目錄架構,這是認識與學習 Plone 系統的良好基礎,上手之後,可以再視開發或佈署的需要,配置更複雜的設定值。

注意: 從 Plone 4.3.4 之後,自動安裝檔只剩 Unix 版本。想在 Windows 安裝最新版 Plone 請先準備好環境,再透過 pip 安裝;或是先安裝 Windows Subsystem for Linux 來取得 Ubuntue, OpenSUSE 環境,後續就跟 Linux 自動安裝檔的動作一致了。

以 Ubuntu Linux 環境使用一般帳號 (初學者不要使用 root 帳號) 為例,只要 Python 版本符合最低要求、事先安裝 C 函式庫套件檔案,就能用自動安裝檔,無痛完成編譯。以 Plone 5.1.x 為例,要搭配 Python 2.7.9+ 版本。

推薦 Ubuntu Linux 的原因,在於它的 C 函式庫支援度最高,以 Plone Maps 模組為例,它要事先安裝 geos 函式庫,如果在 Windows 環境通常要額外安裝 C 編譯器來編輯 C 函式庫原始碼,對初學者可能是項挑戰。

如果手邊沒有合適的安裝環境,還可以到 Heroku 註冊帳號,在雲端環境免費建立 Plone 系統。

假設你的 Ubuntu Linux 已經具備 gcc (GNU C Compiler) 和 make,就可以用一般帳號登入系統,開啟 Shell 操作環境,執行:

$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609

注意:在 Linux 環境使用 root 帳號安裝 Plone,屬於進階的安裝方式,建議初學者不要這樣做。

自動安裝檔

假設使用一般帳號 marr 來操作系統,開啟網址 http://plone.org/download 找到最新的檔案版本,假設下載儲存在 /home/marr 目錄裡,完整的路徑是 /home/marr/Plone-5.x.y-UnifiedInstaller.tgz。

https://lh5.googleusercontent.com/-Kkk-mMMNQcU/UXE3chl5-UI/AAAAAAAAB4U/yzjOD_9CcFU/s651/current-release.png

開啟 Shell 操作環境,把下載的檔案解開:

$ tar xvzf Plone-5.x.y-UnifiedInstaller.tgz

進入解開的目錄,執行 ./install.sh standalone 指令來啟動安裝程序,另外,也可以指定 --target 或 --password 選項值。留意到 install.sh 前面有「./」符號,可參考下列訊息範例:

$ ./install.sh standalone

Testing /usr/bin/python2.7 for Zope/Plone requirements....
/usr/bin/python2.7 looks OK. We'll use it.

Rootless install method chosen. Will install for use by system user marr

Detailed installation log being written to /home/marr/Plone-5.1.4-UnifiedInstaller/install.log
Installing Plone 5.1.4 at /home/marr/Plone

Creating Python virtual environment.
New python executable in /home/marr/Plone/zinstance/bin/python2.7
Also creating executable in /home/marr/Plone/zinstance/bin/python
Installing setuptools, pip, wheel...done.
Installing zc.buildout in virtual environment.
Unpacking buildout cache to /home/marr/Plone/buildout-cache
Copying buildout skeleton
Building Zope/Plone; this takes a while...
Building completed

一切順利的話,最後會出現類似下列的畫面,留意到「管理者帳號密碼」的資訊,以 admin 為管理員帳號,系統會亂數產生一組密碼:

#####################################################################
######################  Installation Complete  ######################
 
Plone successfully installed at /home/marr/Plone
See /home/marr/Plone/zinstance/README.html
for startup instructions
 
Use the account information below to log into the Zope Management Interface
The account has full 'Manager' privileges.
 
  Username: admin
  Password: SF1lnUB1

This account is created when the object database is initialized. If you change
the password later (which you should!), you'll need to use the new password. 
 
Use this account only to create Plone sites and initial users. Do not use it
for routine login or maintenance.

- If you need help, ask in IRC channel #plone on irc.freenode.net.
- The live support channel also exists at http://plone.org/chat
- You can also ask for help on https://community.plone.org
- Submit feedback and report errors at https://github.com/plone/Products.CMFPlone/issues
(For install problems, https://github.com/plone/Installers-UnifiedInstaller/issues)

注意:舊版編譯 PIL 過程可能會遇到問題,通常可以改用 Pillow 來解決。

系統目錄架構

上述步驟完成安裝的 Plone 系統,預設根目錄位置在 /home/marr/Plone,主要的檔案目錄架構如下:

Plone             Plone 系統根目錄
|-- buildout-cache/
|   |-- downloads/
|   `-- eggs
|       |-- Plone-5.x.y-py2.7.egg/           Plone 模組
|       `-- Zope2-2.13.xy-py2.7.egg/         Zope2 模組
`-- zinstance/             Instance 家目錄
  |-- README.html                            說明文件
  |-- adminPassword.txt                      管理員初始密碼檔
  |-- bin/                                   系統執行檔 包括 python pip
  |-- develop-eggs/
  |-- include/
  |-- lib/
  |-- local/
  |-- parts/                                 Zope 與 Plone 主程式目錄
  |-- products/                              Plone 2.x 舊式模組的目錄
  |-- src/                                   自行開發的模組目錄
  |-- var/                                   物件資料庫與日誌檔
  |-- base.cfg
  |-- buildout.cfg                           系統建置設定檔
  |-- develop.cfg                            開發環境的建置設定檔
  |-- lxml_static.cfg
  |-- pip-selfcheck.json
  |-- versions.cfg                           Plone 細項版本資訊
  |-- zope-xy-versions.cfg                   Zope 細項版本資訊
  `-- zopetoolkit-xy-ztk_versions.cfg        ZTK 細項版本資訊

我們將 zinstance 目錄稱為「Instance 家目錄」,這裡存放主要的管理檔案,許多維護工作在這目錄裡進行,包括系統的啟動及關閉。

系統產生的管理員密碼

編譯工作的最後階段,會產生一組 Zope 管理員的帳號密碼,登入管理介面時要輸入這組帳號密碼,除了在螢幕上提示外,也可以事後在 zinstance/adminPassword.txt 檔案裡找到,類似下列內容所示:

Use the account information below to log into the Zope Management Interface
The account has full 'Manager' privileges.

  Username: admin
  Password: SF1lnUB1

This account is created when the object database is initialized. If you change
the password later (which you should!), you'll need to use the new password.

Use this account only to create Plone sites and initial users. Do not use it
for routine login or maintenance.

系統的啟動及關閉

Zope 包含一個 HTTP 伺服器,預設在 8080 埠號執行,啟動 Zope 之前,要確認相關埠號未被佔用。

以上述完成安裝的 Linux 環境為例,它是透過 plonectl (或 instance) 程式來控制系統的啟動及關閉,這程式的位置在 Instance 家目錄的 bin 目錄裡。

第一次啟動時,最好使用 fg 參數,它會通知系統以 foreground 前景方式執行,在 Shell 環境就可以看到執行訊息,最重要的就是要看到 Zope Ready to handle requests 的訊息,這表示系統已就緒可以連線。打開瀏覽器,在網址列輸入 http://localhost:8080/ 之類的網址,就可以看到系統起始畫面。

$ cd ~/Plone/zinstance
$ bin/plonectl fg
... ...
        Hostname: 0.0.0.0
        Port: 8080
... ...
2010-10-20 18:30:54 INFO Zope Ready to handle requests

想要中止的話,按 Ctrl + C 鍵可以結束前景執行。

如果一切順利,之後就可以使用 start 參數來背景執行,執行方式及訊息範例如下:

$ bin/plonectl start
instance: . daemon process started, pid=32054

想要停止系統時,要使用 stop 參數,執行方式如下:

$ bin/plonectl stop
instance: . daemon process stopped

平常可以使用 status 參數來查詢執行狀態:

$ bin/plonectl status
daemon manager not running

初學文件

Creating Website with Plone 4 by taombo

A User's Guide to Plone 4 by EnfoldSystems

常見問題

編譯時遇到 Python.h Missing

在 Ubuntu 可以試 apt-get install python-dev。

執行時遇到 ZConfig.ConfigurationError ... Address already in use

Plone 想要執行的埠號已被佔用,例如預設的埠號是 8080,主機上已有其他程式在同樣的埠號上執行,造成 Plone 無法啟動。處理方式就是讓每個程式同一時間內使用不同的埠號。Plone 啟動時會讀取 zinstance/parts/instance/etc/zope.conf 檔案裡的埠號設定值:

<http-server>
  address 8080
</http-server>

直接把 8080 換成想要的號碼,再重新啟動 Plone 就行。每次執行 bin/buildout 之後,系統會讀取 buildout.cfg 裡的設定值:

[instance]
...
http-address = 8080

重新寫進 zinstance/parts/instance/etc/zope.conf 檔案,想要一勞永逸的話,也可以考慮修改 buildout.cfg 的設定值。

安裝程式的參數細節

推薦使用 ./install.sh standalone --target=/home/marr/plone420 --password=mypass 這樣的指令參數來安裝。

參考資訊

Developer Manual: Installation

系統上 lxml 之類的函式庫版本過於老舊,Plone 4.3 安裝檔必須使用 --static-lxml=yes 參數進行編譯,或參考更多 lxml 說明

Windows Installation Error: Zope is not installed as windows service.

進階安裝

Windows 環境準備 安裝 透過 buildout

只靠 pip 安裝 Plone 5

apt-get install libpq-dev

Change Versions of Vagrant Installation plonedev.vagrant

Ubuntu /etc/init/plone.conf respawn 可使用 root 帳號執行 stop plone 來停止

Miscellaneous Installation Tips

Nix + Docker 各式環境的安裝與啟動

Ubuntu Installation Reference One of the big changes on 16.04 is that python 2.7 is no longer installed by default and that /usr/bin/python may point to python3.5 as well.

RedHat Dependency libz groupinstall

Installing Multiple Versions of Python on Ubuntu from Source

Mac User? from source裝 Xcodebrew install libtiff libjpeg webp little-cms2 就能用 UnifiedInstaller 安裝方式的討論

OpenShift

HotFix 會隨新版本推出時而內建

Windows 安裝及啟用的常見問題:到 var 目錄裡,有看到 *.lock 或 *.pid 檔案的話,例如 instance.lock 或 instance.pid,就把它們刪掉,再重新執行 bin\instance start 試看看。另外,在 Windows 環境下,如果 addon 需要 C compiler,還得額外安裝 Visual Studio 或 MingW 之類的東西,可能是一項挑戰。

簡言之,安裝複雜的 addon 時,使用 Ubuntu Linux 可能較單純,或是請參考 http://plone.org/documentation/kb/using-buildout-on-windows 的說明。