安装门户

Edge for Private Cloud v4.18.05

在安装 Apigee Developer Services 门户(简而言之,门户)之前,请确保:

  1. 您需要先安装 Postgres,然后再安装门户。您可以在安装 Edge 时安装 Postgres,也可以安装 Postgres 独立版本以供门户使用。
    • 如果您独立安装 Postgres,它可以与门户位于同一节点上。
    • 如果您要连接到作为 Edge 的一部分安装的 Postgres,并且 Postgres 是在主/备用模式下进行配置,请指定 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. (可选)安装 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

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 菜单中依次选择报告 > 状态报告,以确保您可以看到门户的当前状态。
  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 属性的值或者角色为 Organization Administrator 的任何用户的凭据一致。

    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 菜单中选择 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 以进行私有云安装,则必须确保 SmartDocs 已安装在 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 下拉菜单中,选择 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 目录中。