安装门户

在安装 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”。

创建门户配置文件

下面显示了门户安装的静默配置文件示例。根据您的配置需要修改此文件。使用 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 选项指定安装 PostgreSQL。配置文件必须可供“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 菜单中选择报告 > 状态报告,确保您可以看到门户的当前状态。
  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_DNS、email 和 password 值一致。用户名和密码还应与初始配置配置文件中的 USER_NAME 和 USER_PWD 属性值一致,或与角色为组织管理员的任何用户的凭据一致。

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

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

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

启用后,您可以使用报告 > 可用更新菜单项查看可用更新。您还可以使用以下 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 菜单中选择模块。
  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 菜单中,依次选择配置 > 开发 > JQuery 更新。
  3. 点击左侧导航栏中的效果。
  4. 在“JQuery and JQuery UI CDN”(JQuery 和 JQuery UI CDN)下拉菜单中,选择 None(无)。
  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 目录中。