概要: 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