安裝入口網站

Edge for Private Cloud 4.19.01 版

安裝 Apigee Developer Services 入口網站 (或簡稱入口網站) 之前,請確認:

  1. 您必須先安裝 Postgres,再安裝入口網站。您可以在安裝 Edge 時一併安裝 Postgres,也可以單獨安裝 Postgres 供入口網站使用。
    • 如果安裝獨立式 Postgres,可以與入口網站位於同一個節點。
    • 如果您要連線至安裝為 Edge 一部分的 Postgres,且 Postgres 已設為主要/待命模式,請指定主要 Postgres 伺服器的 IP 位址。
  2. 您是在 64 位元版本的 Red Hat Enterprise Linux、CentOS 或 Oracle 上執行安裝作業。如需支援的版本清單,請參閱「支援的軟體和版本」。
  3. 已安裝 Yum。

安裝程式僅包含 Apigee Developer Services 入口網站 (或簡稱入口網站) 所需的 Drupal 貢獻模組。如要瞭解如何安裝其他貢獻模組,請參閱「擴充 Drupal 7」。

安裝總覽

如要安裝入口網站,請按照下列步驟操作。以下各節將詳細說明這些步驟。

  1. 測試連線
  2. 移除 7.0 以下版本的 PHP
  3. 安裝 Postgres
  4. 安裝入口網站
  5. 確認已啟用更新管理工具
  6. (選用) 設定 Apache Solr
  7. (選用) 安裝 SmartDocs
  8. (選用) 設定 JQuery

淘汰 SMTPSSL 屬性

在先前的版本中,您可以使用 SMTPSSL 屬性,設定連線至入口網站的 SMTP 伺服器所使用的通訊協定。該屬性已淘汰。

現在,您可以使用 SMTP_PROTOCOL 屬性 (而非 SMTPSSL 屬性),設定連線至入口網站的 SMTP 伺服器所使用的通訊協定。有效值為「standard」、「ssl」或「tls」。

建立入口網站設定檔

以下是入口網站安裝作業的自動設定檔範例。請視設定需要編輯這個檔案。使用 setup.sh 的 -f 選項加入這個檔案。

IP1=IPorDNSnameOfNode

# Must resolve to IP address or DNS name of host - not to 127.0.0.1 or localhost.
HOSTIP=$(hostname -i)

# Specify the name of the portal database in Postgres.
PG_NAME=devportal

# Specify the Postgres admin credentials.
# The portal connects to Postgres by using the 'apigee' user.
# If you changed the Postgres password from the default of 'postgres'
# then set PG_PWD accordingly.
# If connecting to a Postgres node installed with Edge,
# contact the Edge sys admin to get these credentials.
PG_USER=apigee
PG_PWD=postgres

# The IP address of the Postgres server.
# If it is installed on the same node as the portal, specify that IP.
# If connecting to a remote Postgres server,specify its IP address.
PG_HOST=$IP1

# The Postgres user credentials used by the portal
# to access the Postgres database,
# This account is created if it does not already exist.
DRUPAL_PG_USER=drupaladmin
DRUPAL_PG_PASS=portalSecret

# Specify 'postgres' as the database.
DEFAULT_DB=postgres

# Specify the Drupal admin account details.
# DO NOT set DEVPORTAL_ADMIN_USERNAME=admin.
# The installer creates this user on the portal.
DEVPORTAL_ADMIN_FIRSTNAME=firstName
DEVPORTAL_ADMIN_LASTNAME=lastName
DEVPORTAL_ADMIN_USERNAME=userName
DEVPORTAL_ADMIN_PWD=PORTAL_ADMIN_PASSWORD
DEVPORTAL_ADMIN_EMAIL=foo@bar.com

# Edge connection details.
# If omitted, you can set them in the portal UI.
# Specify the Edge organization associated with the portal.
EDGE_ORG=edgeOrgName

# Specify the URL of the Edge management API.
# For a Cloud based installation of Edge, the URL is:
# https://api.enterprise.apigee.com/v1
# For a Private Cloud installation, it is in the form:
# http://ms_IP_or_DNS:8080/v1 or
# https://ms_IP_or_DNS:TLSport/v1
MGMT_URL=https://api.enterprise.apigee.com/v1

# The org admin credentials for the Edge organization in the form
# of Edge emailAddress:pword.
# The portal uses this information to connect to Edge.
DEVADMIN_USER=orgAdmin@myCorp.com
DEVADMIN_PWD=ORG_ADMIN_PASSWORD

# The PHP port.
# If omitted, it defaults to 8888.
PHP_FPM_PORT=8888

# Optionally configure the SMTP server used by the portal.
# If you do, the properties SMTPHOST and SMTPPORT are required.
# The others are optional with a default value as notated below.
# SMTP hostname. For example, for the Gmail server, use smtp.gmail.com.
SMTPHOST=smtp.gmail.com

# Set the SMTP protocol as "standard", "ssl", or "tls",
# where "standard" corresponds to HTTP.
# Note that in previous releases, this setting was controlled by the
# SMTPSSL property. That property has been deprecated.
SMTP_PROTOCOL="standard"

# SMTP port (usually 25).
# The value can be different based on the selected encryption protocol.
# For example, for Gmail, the port is 465 when using SSL and 587 for TLS.
SMTPPORT=25

# Username used for SMTP authentication, defaults is blank.
SMTPUSER=your@email.com

# Password used for SMTP authentication, default is blank.
SMTPPASSWORD=YOUR_EMAIL_PASSWORD

1. 測試與 Apigee Edge 的連線

在入口網站伺服器上執行下列 curl 指令,測試要安裝入口網站的伺服器與 Edge 管理伺服器之間的連線:

curl -u EMAIL:PASSWORD http://ms_IP_or_DNS:8080/v1/organizations/ORGNAME

或是:

curl -u EMAIL:PASSWORD https://ms_IP_or_DNS:TLSPort/v1/organizations/ORGNAME

其中 EMAIL 和 PASSWORD 是 ORGNAME 管理員的電子郵件地址和密碼。

請務必指定 Edge 安裝作業的主機名稱和通訊埠編號。通訊埠 8080 是 Edge 使用的預設通訊埠。如果您要連線至雲端中的組織,要求網址為:https://api.enterprise.apigee.com/v1/organizations/ORGNAME。

如果成功,curl 會傳回類似下列的回應:

{
  "createdAt" : 1348689232699,
  "createdBy" : "USERNAME",
  "displayName" : "cg",
  "environments" : [ "test", "prod" ],
  "lastModifiedAt" : 1348689232699,
  "lastModifiedBy" : "foo@bar.com",
  "name" : "cg",
  "properties" : {
    "property" : [ ]
  },
  "type" : "trial"
}

2. 移除 7.0 以下版本的 PHP

安裝指令碼會在開始安裝前,檢查系統上是否有 7.0 之前的 PHP 版本。如果存在 7.0 之前的 PHP 版本,系統會顯示下列警告訊息:

The following packages present on your system conflict with software we are
about to install. You will need to manually remove each one, then re-run this install script.

php
php-cli
php-common
php-gd
php-mbstring
php-mysql
php-pdo
php-pear
php-pecl-apc
php-process
php-xml

使用下列指令移除 PHP 套件:

yum remove package_name

如果不確定伺服器是否已安裝 PHP,請使用下列指令:

rpm -qa | grep -i php

請注意,入口網站使用的是 PHP 4.18.01-0.0.49 版。這並非要與 Apigee Edge for Private Cloud 的版本號碼相符。

3. 安裝 Postgres

您必須先安裝 Postgres,才能安裝入口網站。您可以在安裝 Edge 時一併安裝 Postgres,也可以單獨安裝 Postgres 供入口網站使用。

  • 如果您連線至安裝為 Edge 一部分的 Postgres,且 Postgres 已設為主要/待命模式,請指定主要 Postgres 伺服器的 IP 位址。
  • 如果安裝獨立式 Postgres,可以與入口網站位於同一個節點。

如要瞭解如何在安裝 Edge 時一併安裝 Postgres,請參閱「在節點上安裝 Edge 元件」。

如要安裝 Postgres 獨立版,請按照下列步驟操作:

  1. 使用網際網路或非網際網路程序,在節點上安裝 Edge apigee-setup 公用程式。詳情請參閱「安裝 Edge apigee-setup 公用程式」。
  2. 建立 Postgres 設定檔,如以下範例所示:
    # Must resolve to IP address or DNS name of host - not to 127.0.0.1 or localhost
    HOSTIP=$(hostname -i)
    
    # The pod and region of Postgres. Use the default values shown below.
    MP_POD=gateway
    REGION=dc-1
    
    # Set the Postgres password. The default value is 'postgres'.
    PG_PWD=postgres
  3. 在命令提示字元執行設定指令碼,安裝 Postgres:
    /opt/apigee/apigee-setup/bin/setup.sh -p pdb -f postgres_config_file

    -p pdb 選項會指定安裝 Postgre。設定檔必須可供「apigee」使用者存取或讀取。

4. 安裝入口網站

安裝入口網站前,請務必按照「3. 安裝 Postgres:

  1. 在入口網站的節點上安裝 Edge apigee-setup 公用程式
  2. 安裝 Postgres,可以單獨安裝,也可以在安裝 Edge 時一併安裝

如要安裝入口網站,請按照下列步驟操作:

  1. 在命令提示字元執行 setup 指令碼:
    /opt/apigee/apigee-setup/bin/setup.sh -p dp -f configFile

    其中:

    • configFile 是入口網站設定檔,如「建立入口網站設定檔」一節所述。
    • -p dp 會指示 setup 指令碼安裝入口網站。

如要確認入口網站是否安裝成功,請按照下列步驟操作:

  1. 前往入口網站首頁 http://localhost:8079,或入口網站的 DNS 名稱。
  2. 使用在入口網站設定檔中設定的管理員憑證登入入口網站。
  3. 在 Drupal 選單中依序選取「Reports」(報表) >「Status Report」(狀態報表),確認您可以查看入口網站的目前狀態。
  4. 確認管理伺服器連線成功。如果不是:
    1. 前往入口網站的「Connection Configuration」(連線設定) 頁面 (例如 http://portal_IP:8079/admin/config/devconnect)。
    2. 點選「Test Connection」按鈕。如果連線成功,就表示設定完成。如果連線失敗,請繼續進行下一個步驟。
    3. 檢查端點和驗證設定:
      • Management API 端點網址:確認通訊協定 (HTTP 或 HTTPS)、IP 或 DNS 名稱,以及通訊埠號碼正確無誤,例如:
        http://10.10.10.10:8080/v1
      • 端點驗證使用者:組織管理員的使用者名稱。
      • Authenticated user's password:組織管理員的密碼。

      預設值會反映您在安裝程序中建立的入口網站設定檔設定。

      這些值應與您在步驟 1:測試與 Apigee Edge 的連線中使用的 ms_IP_or_DNS、email 和 password 值相符。使用者名稱和密碼也應與新手上路設定檔中 USER_NAME 和 USER_PWD 屬性的值相符,或與角色為組織管理員的任何使用者憑證相符。

    4. 成功連線至管理伺服器後,請按一下頁面底部的「Save configuration」(儲存設定) 按鈕,儲存變更。

5. 確認已啟用更新管理員模組

如要接收 Drupal 更新通知,請確認已啟用 Drupal 更新管理員模組。在 Drupal 選單中選取「Modules」,然後向下捲動至「Update manager」模組。如果尚未啟用,請啟用。

啟用後,您可以使用「Reports」>「Available Updates」選單項目查看可用的更新。您也可以使用下列 Drush 指令:

drush pm-info update

您必須從網站的根目錄執行這項指令。入口網站預設安裝在 /opt/apigee/apigee-drupal/wwwroot。因此,請先將目錄變更為 /opt/apigee/apigee-drupal/wwwroot,再執行指令。如果您未將入口網站安裝在預設目錄中,請變更為安裝目錄。

依序點選「Reports」>「Available Updates」>「Settings」選單項目,設定模組在有可用更新時傳送電子郵件給您,並設定檢查更新的頻率。

6. 設定 Apache Solr 搜尋引擎 (選用)

根據預設,安裝入口網站時,連線至 Apache Solr 搜尋引擎的 Drupal 模組會停用。大多數入口網站都使用內部 Drupal 搜尋引擎,因此不需要 Drupal Solr 模組。

如果您決定使用 Solr 做為搜尋引擎,則必須在本機伺服器上安裝 Solr,然後在入口網站上啟用及設定 Drupal Solr 模組。

如要啟用 Drupal Solr 模組,請按照下列步驟操作:

  1. 以具備管理員或內容創作權限的使用者身分,登入入口網站。
  2. 在 Drupal 選單中選取「Modules」。
  3. 啟用 Apache Solr Framework 模組和 Apache Solr Search 模組。
  4. 儲存變更。
  5. 按照 https://drupal.org/node/1999280 的說明設定 Solr。

7. 安裝 SmartDocs (選用)

SmartDocs 可讓您在入口網站上記錄 API,使 API 說明文件完全互動。不過,如要搭配入口網站使用 SmartDocs,您必須先在 Edge 上安裝 SmartDocs。

  • 如果您將入口網站連線至 Edge Cloud 安裝,SmartDocs 已安裝,不需要進一步設定。
  • 如果您要將入口網站連結至 Edge for Private Cloud 安裝項目,請務必確認 Edge 已安裝 SmartDocs。如要進一步瞭解如何安裝 Edge 和 SmartDocs,請參閱「安裝 SmartDocs」。

您也必須在入口網站啟用 SmartDocs。如要進一步瞭解 SmartDocs,請參閱「使用 SmartDocs 記錄 API」。

8. 為非網際網路安裝設定 JQuery Update 模組 (選用)

如果您在非網際網路安裝中安裝及使用 JQuery Update 模組,則必須將模組設定為使用本機版本的 JQuery。如果您將模組設為使用 CDN 進行非網際網路安裝,模組會嘗試存取 CDN,導致網頁載入延遲。如要進一步瞭解 JQuery Update 模組,請參閱 https://www.drupal.org/project/jquery_update。

如要將 JQuery Update 模組設為使用本機版本的 JQuery,請按照下列步驟操作:

  1. 以具備管理員或內容創作權限的使用者身分,登入入口網站。
  2. 在 Drupal 選單中,依序選取「Configuration」>「Development」>「JQuery Update」。
  3. 按一下左側導覽列中的「成效」。
  4. 在「JQuery and JQuery UI CDN」下拉式選單中,選取「None」。
  5. 點按「儲存設定」。

9. 後續步驟

下表列出安裝後最常執行的工作,並提供 Apigee 說明文件的連結,方便您查看更多資訊:

工作 說明

自訂主題

主題會定義入口網站的外觀,包括顏色、樣式和其他視覺效果。

自訂外觀

首頁包含主選單、歡迎訊息、頁首、頁尾和標題。

新增及管理使用者帳戶

註冊程序可控管新開發人員在入口網站註冊帳戶的方式。例如,新開發人員是否能立即存取入口網站,還是必須由管理員驗證。這項程序也會控管系統在建立新帳戶時,如何通知入口網站管理員。

設定電子郵件

入口網站會根據特定事件傳送電子郵件。例如,新開發人員在入口網站註冊時,以及開發人員遺失密碼時。

新增及管理使用者帳戶

新增「條款及細則」頁面,開發人員必須接受條款及細則,才能存取入口網站。

新增及管理使用者帳戶

入口網站採用角色式授權模型。在允許開發人員註冊之前,請先定義入口網站使用的權限和角色。

新增網誌和論壇貼文

入口網站內建網誌和討論串論壇支援。定義查看、新增、編輯及刪除網誌和論壇貼文所需的權限。

務必備份資料庫

請務必備份 Drupal 資料庫。請注意,由於每個安裝作業都不同,因此您必須自行決定備份資料庫的最佳方式。

另請參閱「如何執行備份」。

設定主機名稱

如果您未在 DNS 伺服器中設定主機名稱,則一律可以透過伺服器的 IP 位址存取網站。如要使用主機名稱,可以為伺服器設定 DNS,這樣應該就能正常運作,不必在基本設定中進行其他設定。

如果您設定了負載平衡器,或因其他原因導致網站網址不正確,可以按照下列步驟為 Drupal 設定 $base_url:

  1. 如果目錄 /opt/apigee/data/apigee-drupal-devportal/sites/default/includes 不存在,請建立該目錄。
  2. 在該目錄中建立名為 settings.php 的檔案。
  3. 將下列內容新增至 settings.php 檔案:
    /**
    * Base URL (optional).
    *
    * If Drupal is generating incorrect URLs on your site, which could
    * be in HTML headers (links to CSS and JS files) or visible links
    * on pages (such as in menus), uncomment the Base URL statement
    * below (remove the leading hash sign) and fill in the absolute URL
    * to your Drupal installation.
    *
    * You might also want to force users to use a given domain.
    * See the .htaccess file for more information.
    *
    * Examples:
    *   $base_url = 'http://www.example.com';
    *   $base_url = 'http://www.example.com:8888';
    *   $base_url = 'http://www.example.com/drupal';
    *   $base_url = 'https://www.example.com:8888/drupal';
    *
    * It is not allowed to have a trailing slash; Drupal will add it
    * for you.
    */
    # $base_url = 'http://www.example.com/';  // NO trailing slash!
    $base_url = ‘http://www.example.com’;
  4. 將最後一行 $base_url 變更為網站的主機名稱。
  5. 儲存檔案。

請注意,您可以在這個檔案中加入 /opt/apigee/data/apigee-drupal-devportal/ sites/default/default.settings.php 的任何其他設定。

如要進一步瞭解 $base_url 屬性,請參閱下列資源:

自訂開發 您也可以使用主題以外的自訂程式碼,擴充入口網站的功能。如要這麼做,請按照 Drupal 的模組開發主題所述,建立自己的 Drupal 模組,並將模組放在 /sites/all/modules 目錄中。