为 SharePoint Server 配置 Office Online ServerConfigure Office Online Server for SharePoint Server

摘要: 了解如何将 SharePoint Server 配置为使用 Office Online Server (Office Web Apps Server 的下一个版本)。Summary: Learn how to configure SharePoint Server to use Office Online Server (the next version of Office Web Apps Server).

目标用户:IT 专业人员Audience: IT Professionals

本文将介绍 部署 Office Online Server 中没有涵盖的内容。This article picks up where Deploy Office Online Server left off. 在另一文章中,你设置了运行 Office Online Server 的本地服务器。In that article, you set up the server that runs Office Online Server on-premises. 在这种情况下, 将 SharePoint Server 配置为使用 Office Online Server。In this one, you'll configure SharePoint Server to use Office Online Server. 首先, 你需要从 SharePoint Server 2016 运行几个 Microsoft PowerShell cmdlet, 之后用户将能够在浏览器中从 SharePoint Server 文档库中打开 Office 文件。First, you'll need to run a few Microsoft PowerShell cmdlets from SharePoint Server 2016, after which users will be able to open Office files from SharePoint Server document libraries in a browser.

将 SharePoint Server 配置为使用 Office Online Server 前Before you configure SharePoint Server to use Office Online Server

在开始之前检查几个事项:A few things to check before getting started:

  • 这些说明也适用于 SharePoint Server 2013, 但是, SharePoint Server 2013 无法在 Office Online Server 中使用 Excel Online 外部数据连接和数据刷新功能。These instructions also apply to SharePoint Server 2013, however SharePoint Server 2013 cannot use the Excel Online external data connectivity and data refresh functionality in Office Online Server.

  • 安装 SharePoint Server 2016。Install SharePoint Server 2016. 请参阅安装 SharePoint Server for 指南。See Install SharePoint Server for guidance.

  • 确保所有 SharePoint Server 2016 Web 应用程序都使用基于声明的身份验证。Office Online 呈现和编辑将对使用经典模式身份验证的 SharePoint Server 2016 Web 应用程序不起作用。Make sure all SharePoint Server 2016 web applications use claims-based authentication. Office Online rendering and editing won't work on SharePoint Server 2016 web applications that use classic mode authentication.

  • 若要使用户能够在 Web 浏览器中编辑(而不仅仅是阅读)Office 文档,你需要一个编辑许可证。此外,还将需要启用对 Office Online Server 场的编辑。To enable users to edit (not just read) Office documents in a web browser, you'll need an editing license. Also, you'll need to enable editing on the Office Online Server farm.

  • 如果您使用系统帐户登录到 SharePoint Server 2016,则将无法测试 SharePoint Server 2016 和 Office Online Server 之间的连接。使用其他帐户登录,以测试连接。If you log on to SharePoint Server 2016 by using the System Account, you won't be able to test the connection between SharePoint Server 2016 and Office Online Server. Log on with a different account to test the connection.

  • 内存不足的情况可能会导致 Office Online 中的 Office 文档预览失败。Low memory conditions can cause Office document previews to fail in Office Online.

  • SharePoint Server 2013 无法在 Office Online Server 中使用 Excel Online 外部数据连接和数据刷新功能。SharePoint Server 2013 cannot use the Excel Online external data connectivity and data refresh functionality in Office Online Server. 仅在 SharePoint Server 2016 中可用。That's only available with SharePoint Server 2016.

  • Office Online Server 使用 OAuth 令牌与 SharePoint Server 进行通信。Office Online Server uses OAuth tokens to communicate with SharePoint Server. 这些令牌可能会被截取和重播, 为攻击者提供了与发出 SharePoint Server 到 Office Online Server 请求的用户相同的权限。These tokens can potentially be intercepted and replayed, providing an attacker with the same rights as the user making the request from SharePoint Server to Office Online Server. 强烈建议您将 Office Online Server 配置为仅使用 HTTPS (TLS)。It is strongly recommended that you configure Office Online Server to use HTTPS (TLS) only.

配置 SharePoint Server 以使用 Office Online ServerConfigure SharePoint Server to use Office Online Server

选择下列章节之一,具体取决于您要使用 HTTP 还是 HTTPS。HTTP 通常仅建议用于测试环境。在生产环境中,最好使用更为安全的 HTTPS 协议。Choose one of the following sections depending on whether you want to use HTTP or HTTPS. HTTP is generally recommended only for test environments. In production environments, the more secure HTTPS protocol is the better choice.

在使用 HTTP 的测试环境中In a test environment that uses HTTP

对于此配置,请确保已按照 部署使用 HTTP 的单服务器 Office Online Server 场的步骤设置 Office Online Server。确保将 Office Online Server 场配置为使用内部 URL 和 HTTP。For this configuration, make sure you have set up Office Online Server by following the steps in Deploy a single-server Office Online Server farm that uses HTTP. Be sure to configure the Office Online Server farm to use an internal URL and HTTP.

步骤 1:创建 SharePoint 2016 和 Office Web Apps Server 之间的绑定Step 1: Create the binding between SharePoint 2016 and Office Web Apps Server

若要开始, 请打开提升的 SharePoint 2016 命令行管理程序。To get started, open an elevated SharePoint 2016 Management Shell. (右键单击 " SharePoint 2016 命令行管理程序", 然后单击 "以管理员身份运行"。)(Right-click SharePoint 2016 Management Shell, and then click Run as Administrator.)

运行以下命令,其中 是您为内部 URL 设置的完全限定的域名 (FQDN)。这是 Office Online Server 流量的入口点。对于此测试环境,您必须指定 -AllowHTTP 参数以允许 SharePoint Server 2016 通过使用 HTTP 接收来自 Office Online Server 服务器场的发现信息。如果您未指定 -AllowHTTP,则 SharePoint Server 2016 将尝试使用 HTTPS 与 Office Online Server 服务器场进行通信,并且此命令将失败。Run the following command, where is the fully qualified domain name (FQDN) of the URL that you set for the internal URL. This is the point of entry for Office Online Server traffic. For this test environment, you need to specify the -AllowHTTP parameter to allow SharePoint Server 2016 to receive discovery information from the Office Online Server farm by using HTTP. If you don't specify -AllowHTTP, SharePoint Server 2016 will try to use HTTPS to communicate with the Office Online Server farm, and this command won't work.


New-SPWOPIBinding -ServerName <WacServerName> -AllowHTTP

运行此命令后,您应看到 Microsoft PowerShell 命令提示符处显示了一个绑定列表。After running this command, you should see a list of bindings displayed at the Microsoft PowerShell command prompt.

步骤 2:查看针对 SharePoint 绑定的 WOPI 区域Step 2: View the WOPI zones for the SharePoint bindings

Office Online Server 使用区域来确定其与主机(此示例中为 SharePoint Server 2016)进行通信时将使用的 URL(内部或外部)和协议(HTTP 或 HTTPS)。默认情况下,SharePoint Server 2016 使用 internal-https 区域。通过运行以下命令来确认这是当前区域:Office Online Server uses zones to determine which URL (internal or external) and which protocol (HTTP or HTTPS) to use when it communicates with the host, in this case, SharePoint Server 2016. By default, SharePoint Server 2016 uses the internal-https zone. Run the following command to see what your current zone is.

Get-SPWOPIZone

此命令显示的 WOPI 区域应该是 internal-http。如果显示正确,请跳至步骤 4,否则请参阅下一步。The WOPI zone displayed by this command should be internal-http. If it's displayed correctly, skip to step 4. If it isn't, see the next step.

步骤 3:将 WOPI 区域更改为 internal-httpStep 3: Change the WOPI zone to internal-http

如果通过执行步骤 3 获得的结果为 internal-https,则运行以下命令可将区域更改为 internal-http。您需要进行此更改,因为 SharePoint Server 2016 的区域必须匹配 Office Online Server 服务器场的区域。If the result from Step 3 was internal-https, run the following command to change the zone to internal-http. You need to make this change because the zone of SharePoint Server 2016 must match the zone of the Office Online Server farm.

Set-SPWOPIZone -zone "internal-http"

再次运行 Get-SPWOPIZone ,确认新的区域为 internal-httpVerify that the new zone is internal-http by running Get-SPWOPIZone again.

步骤 4:将 SharePoint 2016 中的 AllowOAuthOverHttp 设置更改为 TrueStep 4: Change the AllowOAuthOverHttp setting in SharePoint 2016 to True

若要在测试环境中通过 HTTP 将 SharePoint Server 2016 与 Office Online 结合使用,您需要将 AllowOAuthOverHttp 设置为"True"。否则,Office Online 将不起作用。可通过运行以下示例来检查当前状态:To use Office Online with SharePoint Server 2016 over HTTP in a test environment, you need to set AllowOAuthOverHttp to True. Otherwise Office Online won't work. You can check the current status by running the following example.

(Get-SPSecurityTokenServiceConfig).AllowOAuthOverHttp

如果此命令返回 False,则运行下列命令可将其设置为 TrueIf this command returns False, run the following commands to set this to True.

$config = (Get-SPSecurityTokenServiceConfig)
$config.AllowOAuthOverHttp = $true
$config.Update()

再次运行以下命令来验证 AllowOAuthOverHttp 设置现在是否设置为 TrueRun the following command again to verify that the AllowOAuthOverHttp setting is now set to True.

(Get-SPSecurityTokenServiceConfig).AllowOAuthOverHttp

步骤 5:启用 Excel SOAP APIStep 5: Enable the Excel SOAP API

通过 Excel Online 计划数据刷新和 Excel Web 部件呈现需要 Excel SOAP API。若要启用 Excel SOAP API,需要将 WopiLegacySoapSupport 属性添加到 PowerShell 使用的 SharePoint Server 场属性。 输入的参数是 ExcelServiceInternal.asmx 的 URL。此 URL 可以通过负载平衡为多 OOS 服务器寻址。 只需将 替换为 Office Online Server 路径。The Excel SOAP API is needed for scheduled data refresh with Excel Online, and for Excel Web Part rendering. To enable the Excel SOAP API, you need to add the WopiLegacySoapSupport property to the SharePoint Server farm properties using by PowerShell. The input parameter is the URL to ExcelServiceInternal.asmx. This URL can address multiple OOS servers via load balancing. Simply replace the with your Office Online Server path.

若要启用 Excel SOAP API,请运行以下 PowerShell,其中 是 Office Online Server 场的 URL。(例如,http://OfficeOnlineServer.contoso.com.)。)To enable the Excel SOAP API, run the following PowerShell where is the URL of your Office Online Server farm. (For example, http://OfficeOnlineServer.contoso.com.)


$Farm = Get-SPFarm
$Farm.Properties.Add("WopiLegacySoapSupport", "<URL>/x/_vti_bin/ExcelServiceInternal.asmx");
$Farm.Update();

步骤 6:验证 Office Web Apps 是否正常运行Step 6: Verify that Office Web Apps is working

在 SharePoint Server 2016 中,确保您不是作为系统帐户登录的,否则您将无法使用 Office Online 编辑或查看文档。转到包含 Office 文档的 SharePoint Server 2016 文档库并查看 Word、PowerPoint、Excel 或 OneNote 文件。文档应该在使用 Office Online 显示文件的浏览器中打开。In SharePoint Server 2016, make sure you're not logged on as System Account because you won't be able to edit or view the documents with Office Online. Go to a SharePoint Server 2016 document library that contains Office documents and view a Word, PowerPoint, Excel, or OneNote file. The document should open in a browser that displays the file by using Office Online.

在使用 HTTPS 的生产环境中In a production environment that uses HTTPS

在开始下列过程之前,请确保已通过执行 部署使用 HTTPS 的单服务器 Office Online Server 场部署使用 HTTPS 的多服务器负载平衡 Office Online Server 场中的步骤来设置 Office Online Server。Before you start the following procedures, make sure that you have set up Office Online Server by following the steps in Deploy a single-server Office Online Server farm that uses HTTPS or Deploy a multi-server, load-balanced Office Online Server farm that uses HTTPS.

步骤 1:创建 SharePoint 2016 和 Office Online Server 之间的绑定Step 1: Create the binding between SharePoint 2016 and Office Online Server

开始前,打开提升的 SharePoint 2016 命令行管理程序。(右键单击" SharePoint 2016 命令行管理程序",然后单击" 以管理员身份运行"。)To get started, open an elevated SharePoint 2016 Management Shell. (Right-click SharePoint 2016 Management Shell, and then click Run as Administrator.)

运行以下命令,其中 是您为内部 URL 设置的完全限定域名 (FQDN)。这是 Office Online Server 流量的入口点。Run the following command, where is the fully qualified domain name (FQDN) of the URL that you set for the internal URL. This is the point of entry for Office Online Server traffic.


New-SPWOPIBinding -ServerName <WacServerName> 

步骤 2:查看 SharePoint 2016 的 WOPI 区域Step 2: View the WOPI zone of SharePoint 2016

Office Online Server 使用区域来确定其与主机(此示例中为 SharePoint Server 2016)进行通信时将使用的 URL(内部或外部)和协议(HTTP 或 HTTPS)。默认情况下,SharePoint Server 2016 使用 internal-https 区域。通过运行以下命令来确认这是当前区域。Office Online Server uses zones to determine which URL (internal or external) and which protocol (HTTP or HTTPS) to use when it communicates with the host, which in this case is SharePoint Server 2016. By default, SharePoint Server 2016 uses the internal-https zone. Verify that this is the current zone by running the following command.

Get-SPWOPIZone

请记下显示的 WOPI 区域。Take note of the WOPI zone that is displayed.

步骤 3:如有必要更改 WOPI 区域Step 3: Change the WOPI zone if necessary

根据您的环境,您可能需要更改 WOPI 区域。如果您有一个既为内部又为外部的 SharePoint 场,则指定外部。如果您有一个仅内部的 SharePoint 场,则指定内部。Depending on your environment, you might have to change the WOPI zone. If you have a SharePoint farm that's both internal and external, specify external. If you have a SharePoint farm that's internal only, specify internal.

如果通过执行步骤 2 获得的结果显示 internal-https 且 SharePoint 场仅是内部的,则可以跳过此步骤。如果具有既为内部又为外部的 SharePoint 场,则需要运行以下命令来将区域更改为 external-httpsIf the results from Step 2 show that internal-https and the SharePoint farm is internal only, you can skip this step. If you have a SharePoint farm that's internal and external, you need to run the following command to change the zone to external-https.

Set-SPWOPIZone -zone "external-https"

步骤 4:启用 Excel SOAP APIStep 4: Enable the Excel SOAP API

通过 Excel Online 计划数据刷新和 Excel Web 部件呈现需要 Excel SOAP API。若要启用 Excel SOAP API,需要将 WopiLegacySoapSupport 属性添加到 PowerShell 使用的 SharePoint Server 场属性。 输入的参数是 ExcelServiceInternal.asmx 的 URL。此 URL 可以通过负载平衡为多 OOS 服务器寻址。 只需将 替换为 Office Online Server 路径。The Excel SOAP API is needed for scheduled data refresh with Excel Online, and for Excel Web Part rendering. To enable the Excel SOAP API, you need to add the WopiLegacySoapSupport property to the SharePoint Server farm properties using by PowerShell. The input parameter is the URL to ExcelServiceInternal.asmx. This URL can address multiple OOS servers via load balancing. Simply replace the with your Office Online Server path.

若要启用 Excel SOAP API,请运行以下 PowerShell,其中 是 Office Online Server 场的 URL。(例如,https://OfficeOnlineServer.contoso.com.)。)To enable the Excel SOAP API, run the following PowerShell where is the URL of your Office Online Server farm. (For example, https://OfficeOnlineServer.contoso.com.)


$Farm = Get-SPFarm
$Farm.Properties.Add("WopiLegacySoapSupport", "<URL>/x/_vti_bin/ExcelServiceInternal.asmx");
$Farm.Update();

步骤 5:验证 Office Web Apps 是否正常运行Step 5: Verify that Office Web Apps is working

在 SharePoint Server 2016 中,确保您不是作为系统帐户登录的,否则您将无法使用 Office Online 编辑或查看文档。转到包含 Office 文档的 SharePoint Server 2016 文档库并查看 Word、PowerPoint、Excel 或 OneNote 文件。文档应该在使用 Office Online 显示文件的浏览器中打开。In SharePoint Server 2016, make sure you aren't logged on as System Account because you won't be able to edit or view the documents with Office Online. Go to a SharePoint Server 2016 document library that contains Office documents and view a Word, PowerPoint, Excel, or OneNote file. The document should open in a browser that displays the file by using Office Online.

断开 SharePoint Server 2016 与 Office Online Server 的连接Disconnect SharePoint Server 2016 from Office Online Server

如果出于任何原因需要断开 SharePoint Server 2016 与 Office Online Server 的连接,请使用以下命令示例。If, for any reason, you want to disconnect SharePoint Server 2016 from Office Online Server, use the following command example.


Remove-SPWOPIBinding -All:$true