概要: Before Node.js applications can be hosted in Plesk, Node.js support must be enabled.

In this topic, you will learn how to enable the support for Node.js hosting in Plesk. You will also learn how to control which Node.js versions are available, whether Node.js is available to customers, and also how to make Node.js applications’ logs visible or invisible to customers.

If you want to learn how to host and manage Node.js applications in Plesk, read the Hosting Node.js Applications topic instead.

启用Node.js 支持

Before your customers and resellers can host Node.js applications, the free Node.js Toolkit extension must be installed on the Plesk server from the Extensions Catalog <installing-extensions>`.

管理 Node.js 版本

Plesk 支持Node.js 最新稳定版和 LTS版,但有以下局限性:

  • (Plesk for Linux) Multiple Node.js versions can be installed simultaneously, and Node.js applications on different domains can use any available Node.js version.
  • (Plesk for Windows) 目前只能安装一个 Node.js 版本,用于支持服务器上所有的 Node.js 应用。

To see what Node.js versions are installed on the server, go to Extensions, open the “My Extensions” tab, and then click Open next to the “Node.js Toolkit” extension.

image nodejs versions

Here you can see the Node.js versions installed on the server. Versions marked with the image enabled icon icon are enabled, and those marked with the image disabled icon are disabled. You can also see the paths to their corresponding binaries, and also the number of domains using a particular Node.js version. In Plesk for Linux, you may also see one or more Node.js versions available for installation.

Disabling or enabling a Node.js version:

  1. 登录到 Plesk
  2. Go to to Extensions, open the “My Extensions” tab, and then click Open next to the “Node.js Toolkit” extension.
  3. Click the image enabled icon icon for an enabled Node.js version to disable it.
  4. Click the image disabled icon icon for a disabled Node.js version to enable it.

Disabling a Node.js version has the following effects:

  • 当管理域名的 Node.js 应用时则无法再选择被禁用的 Node.js 版本。
  • 现有的 Node.js 应用会被切换到其它启用的Node.js 版本(如果可能)。
  • 如果服务器上所有的 Node.js 版本都已被禁用,则会导致所有现存 Node.js 应用停止运行,也会移除对域名的 Node.js 应用的管理功能,直到至少重新启用了一个Node.js 版本。

(Plesk for Linux) Installing or uninstalling a Node.js version:

  1. 登录到 Plesk
  2. Go to to Extensions, open the “My Extensions” tab, and then click Open next to the “Node.js Toolkit” extension.
  3. If the Node.js version you want to uninstall is enabled, click the image enabled icon icon to disable it first.
  4. Click Uninstall for a disabled Node.js version to uninstall it.
  5. Click Install for a Node.js version that is not installed to install it.

(Plesk for Windows) Changing the installed Node.js version:

  1. 登录到 Plesk
  2. Go to Tools & Settings, click Updates (under “Plesk”), and then click Add/Remove Components.
  3. Expand the “Node.js hosting features” section, select the desired Node.js version under the “Node.js Engine” component, and then click Continue.

控制 Node.js 是否开放给客户使用

启用 Node.js 支持会给服务方案和订阅添加以下权限,您可以使用常规的客户权限访问 Node.js 功能:

  • “Node.js support management” 允许客户为其域名启用Node.js 支持。
  • “Node.js state management” 允许客户为其应用更改应用模式。
  • “Node.js version management” 允许客户为其应用更改 Node.js 版本。

管理Node.js应用程序日志的可见性

Node.js应用程序将其日志(包括应用程序的控制台输出)写入以下位置:

  • (Plesk for Linux) /var/log/passenger/passenger.log
  • (Plesk for Windows) %plesk_vhosts%<webspace_name>\logs\iisnode

如果需要排除Node.js应用程序的故障,查看这些日志会很有用。

默认情况下,您以及您的客户和代理商可以在 域名日志浏览器中查看Node.js应用程序的日志。您可以通过 panel.ini 文件在域名日志浏览器中管理这些日志的可见性。

要在域名日志浏览器中管理Node.js应用程序日志的可见性,请如下操作:

  1. 打开位于此处的用于编辑的 panel.ini文件:

    • (Plesk for Linux) /usr/local/psa/admin/conf/panel.ini
    • (Plesk for Windows) %plesk_dir%admin\conf\panel.ini

    您还可以使用`Panel.ini Editor <https://www.plesk.com/extensions/panel-ini-editor/>`__ 扩展在Plesk界面中编辑该文件。

  2. [ext-nodejs] 下,添加以下行并保存文件:

    • (要显示日志) showApplicationLogs = true
    • (要隐藏日志) showApplicationLogs = false