安裝入口網站

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

  1. 請先安裝 Postgres,再安裝入口網站。您可以安裝 Postgres 來安裝 Edge,或是安裝 Postgres 並用於入口網站。
    • 如果您單獨安裝 Postgres,該節點可能與入口網站所在的節點相同。
    • 如果您要連線至以 Edge 形式安裝的 Postgres,並在 Post/res 中設定主要/待命模式,請指定主要 Postgres 伺服器的 IP 位址。
  2. 您正在執行 Red Hat Enterprise Linux、CentOS 或 Oracle 支援的 64 位元版本。請參閱支援的軟體和支援版本中的支援版本清單。
  3. 已安裝 Yum。

安裝程式只包含由 Apigee 開發人員服務入口網站 (或簡稱入口網站) 所需的 Drupal 貢獻的模組。如要進一步瞭解如何安裝其他提供的模組,請參閱「擴充 Drupal 7」一文。

安裝總覽

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

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

淘汰 SMTPSSL 屬性

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

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

建立入口網站設定檔

以下是入口網站安裝的忽略設定檔範例。視需要編輯這項設定。使用 -f 選項 setup.sh,即可納入這個檔案。

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 的連線

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

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

其中 EMAILPASSWORDORGNAME 的電子郵件地址和密碼。

請務必指定您安裝 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 的私有雲版本號碼不同。

3. 安裝 Postgres

您必須安裝 Postgres 才能安裝入口網站。您可以安裝 Postgres 來安裝 Edge,或是安裝 Postgres 並用於入口網站。

  • 如果您要連線至以 Edge 形式安裝的 Postgres,並在 Post/res 中設定主要/待命模式,請指定主要 Postgres 伺服器的 IP 位址。
  • 如果您單獨安裝 Postgres,該節點可能與入口網站所在的節點相同。

如要進一步瞭解如何安裝 Edgeg 並安裝 Edge,請參閱「在節點上安裝 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,獨立 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. 前往入口網站的「連線設定」頁面 (例如 http://portal_IP:8079/admin/config/devconnect)。
    2. 按一下「測試連線」按鈕。如果連線成功,就大功告成。如果連線失敗,請繼續操作。
    3. 檢查端點和驗證設定:
      • Management API 端點網址:請檢查通訊協定 (HTTP 或 HTTPS)、IP 或 DNS 名稱和通訊埠號碼皆正確無誤;例如:
        http://10.10.10.10:8080/v1
      • 端點驗證使用者:機構管理員的使用者名稱。
      • 通過驗證的使用者密碼:機構管理員的密碼。

      預設值代表您在安裝程序期間建立的入口網站設定檔中的設定。

      這些值應與您在步驟 1:測試連線至 Apigee Edge 時使用的 ms_IP_or_DNSemailpassword 值相符。使用者名稱和密碼也必須與新手上路設定檔中的 USER_NAMEUSER_PWD 屬性值相符,或是角色為「機構管理員」的任何憑證。

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

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

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

啟用後,您可以使用「報告」>「可用更新」選單項目來查看可用的更新。你也可以使用以下「筆刷」指令:

drush pm-info update

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

依序前往「報告」>「可用更新」>「設定」選單項目,即可設定模組在有可用更新時傳送電子郵件通知您,並設定檢查更新的頻率。

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. 安裝 SmartDoc (選用)

SmartDoc 可讓您透過 API 將 API 記錄到與 API 文件完全互動的方式。不過,如要使用入口網站來使用 SmartDoc,您必須先在 Edge 上安裝 SmartDoc。

  • 如果您將入口網站連線至 Edge Cloud 安裝作業,則已安裝 SmartDoc,不需要進行額外設定。
  • 如要將入口網站連線至 Edge 進行私有雲的安裝作業,您必須確認已在 Edge 上安裝 SmartDoc。如要進一步瞭解如何安裝 Edge 和 SmartDoc,請參閱「安裝 SmartDoc」。

您也必須啟用入口網站上的 SmartDoc。如要進一步瞭解 SmartDoc,請參閱「使用 SmartDoc 來記錄 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」>「開發」>「JQuery Update」
  3. 按一下左側導覽面板中的「成效」
  4. 在 JQuery 和 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 目錄。