安装门户

在安装 Apigee 开发者服务门户(或简称为门户)之前,请确保:

  1. 您需要先安装 Postgres 才能安装该门户。您可以在安装 Edge 的过程中安装 Postgres,也可以独立安装 Postgres 供门户使用。
    • 如果安装 Postgres 独立版本,它可以与门户位于同一节点上。
    • 如果您要连接到作为 Edge 的一部分安装的 Postgres,并且 Postgres 配置为主/备用模式,请指定主 Postgres 主服务器的 IP 地址。
  2. 您是在受支持的 64 位版本的 Red Hat Enterprise Linux、CentOS 或 Oracle 上执行安装。如需查看支持的版本列表,请参阅支持的软件和支持的版本
  3. Yum 已安装。

安装程序仅包含 Apigee 开发者服务门户所需的 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”。

创建门户配置文件

门户安装示例静默配置文件如下所示。根据您的配置需要修改此文件。使用 -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 的连接

通过在门户服务器上执行以下 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 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. 进入门户“连接配置”页面(例如 http://portal_IP:8079/admin/config/devconnect)。
    2. 点击 Test Connection 按钮。如果连接成功,则表示操作已完成。如果连接失败,请继续。
    3. 检查端点和身份验证设置:
      • Management API 端点网址:检查协议(HTTP 或 HTTPS)、IP 或 DNS 名称和端口号是否正确;例如:
        http://10.10.10.10:8080/v1
      • 已通过端点身份验证的用户:组织管理员的用户名。
      • 经过身份验证的用户密码:组织的密码。

      默认值反映了您在安装过程中创建的门户配置文件中的设置。

      这些值应与您在第 1 步:测试与 Apigee Edge 的连接中使用的 ms_IP_or_DNSemailpassword 值一致。 用户名和密码还应与新手入门配置文件中的 USER_NAMEUSER_PWD 属性的值,或者角色为 Organization Administrator 的任何用户的凭据相匹配。

    4. 成功连接到管理服务器后,点击页面底部的保存配置按钮以保存更改。

5. 确保已启用更新管理器模块

如需接收 Drupal 更新通知,请确保已启用 Drupal Update 管理器模块。从 Drupal 菜单中,选择 Modules,然后向下滚动到 Update manager 模块。如果未启用,请启用。

启用后,您可以使用报告 > 可用更新菜单项来查看可用更新。您也可以使用以下 Drush 命令:

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. 安装 SmartDocs(可选)

借助 SmartDocs,您可以在门户上以 API 文档完全互动的方式记录您的 API。不过,如需通过门户使用 SmartDocs,您必须先在 Edge 上安装 SmartDocs。

  • 如果您要将门户连接到 Edge Cloud 安装,则智能文档已安装,无需进一步配置。
  • 如要将该门户连接到适用于私有云的 Edge,则必须确保 SmartDoc 安装在 Edge 上。如需详细了解如何安装 Edge 和 SmartDocs,请参阅安装 SmartDocs

您还必须在此门户上启用 SmartDocs。如需详细了解 SmartDocs,请参阅使用 SmartDocs 记录 API

8. 为非互联网安装配置 JQuery 更新模块(可选)

如果您在非互联网安装中安装和使用 JQuery 更新模块,则需要将该模块配置为使用本地版本的 JQuery。如果您将该模块配置为使用 CDN 进行非互联网安装,该模块会尝试访问 CDN,进而导致网页加载延迟。如需详细了解 JQuery 更新模块,请参阅 https://www.drupal.org/project/jquery_update

要将 JQuery 更新模块配置为使用本地版本的 JQuery,请执行以下操作:

  1. 以拥有管理员权限或内容创建权限的用户登录门户。
  2. 在 Drupal 菜单中,依次选择 Configuration > Development > JQuery Update
  3. 点击左侧导航栏中的效果
  4. 在 JQuery 和 JQuery 界面 CDN 下拉菜单中,选择
  5. 点击 Save configuration(保存配置)。

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 目录中。