How to add Node.js projects in the panel
To add a Node.js project, follow these steps:
- Install Node.js
- Add permissions to a user
- Create a site for a project with Node.js
- Add a Node.js project
- Functional check
Install Node.js
To work with projects on Node.js install it in the panel:
- In the Main menu select Settings.
- From the drop-down menu select Software configuration.
- Select Node.js in the form that opens and click Install.
Add permissions to a user
After Node.js is installed in the panel, add usage rights to the user under whom Node.js projects will be added, to do this:
- In the Main menu select Users.
- Select the appropriate user and click on Edit.
- On the form that opens, find the Access section.
- Enable the Node.js checkbox and click Save.
- After saving, the Node.js icon will be displayed in the Status column of the user.
Create a site for a project with Node.js
Now you need to create a site with a Node.js handler, to do this:
- In the Main menu select Sites.
- On the form that opens, click on Create website.
- Select the Extended settings tab (for a detailed description of the settings, see Add a website) and fill in the required fields. Below are the important fields when creating a site with a Node.js project:
- Main settings section:
- Domain name – the domain name;
- Website directory– the path to the website directory that is relative to the owner's home directory;
- Website aliases – additional names of your site (optional field);
- Handler – select Node.js;
- SSL certificate – select an SSL certificate that will be used for this website. You can specify the existing certificate or create a new self-signed certificate;
- IP-address – the list of IP addresses assigned to the website;
- Website owner – select the website owner;
- Default website (checkbox) – if the website is marked as default, it will process a request by the domain name which is not registered on this webserver (including requests by IP) to any IP address assigned to this website;
- Handler section (Node.js):
- Main settings section:
- Click on Create.
On the Sites page, the created website will be added with the Node.js icon in the Parameters column.
Add a Node.js project
Add your Node.js project to the created site by doing the following:
- In the Main menu select Sites.
- Select the required site and click on the Website files button.
- On the File Manager form that opens, click Upload.
- Select where you want to upload the files from:
- Local computer file – click on Choose file or move the necessary files to the drag-and-drop area;
- File URL on remote server:
- URL – a link to the file to be uploaded, for example, http://example.com/dir/file.html;
- Имя файла – the name of the file to be saved with in the current directory. If you leave this field blank, the file name will be extracted from the URL.
- Make sure package.json и server.js contain the correct values for your project.
- Click on Back to the list of websites arrow.
- Click on “…“ and select Npm install.
Npm install will install all the specified packages of your project. The installation process is indicated by a blinking Node.js icon in the Parameters column. - After installation is complete, click on the “…“ button and select Restart (Node.js).
The project will be restarted; the Node.js icon will turn green, which means the project is working properly.
Functional check
To check if it works:
- If the Unix family OS is installed on the PC, add the following entry to the /etc/hosts file: where:
1.1.1.1 example.com
- 1.1.1.1 — is the IP-address of your server;
- example.com — the website name;
- If Windows OS is installed on the PC, add the following entry to the C:\windows\system32\drivers\etc\hosts file: where:
1.1.1.1 example.com
- 1.1.1.1 — the IP-address of your server;
- example.com — your website name.
Enter the name of the website in your browser to check if it was created correctly.