You can add multiple websites to your HestiaCP using different ports for each one.
When you create the app with the installer, it automatically creates:
- /home/%USER%/%DOMAIN%/private/nodeapp directory
- Config for nginx to use the selected port
- ecosystem.config.js with the necessary command to connect pm2 and run your app (e.g.,
npm run start
) - .nvmrc file with the node version if you use NVM
-
Install Node: (Using one of these options)
-
Install PM2
-
Clone this repository:
cd ~/tmp git clone https://github.com/dawgcodes/hestiacp-nodejs.git cd hestiacp-nodejs
-
Use install.sh:
sudo chmod 755 install.sh sudo ./install.sh
-
🚀 You are ready to install an App!!!
- Create a new user (If you already have one, no need to create a new one).
- The user needs bash access for the app to work. Go to User edit > Advanced Options > SSH Access > bash.
- Add a new web (e.g.,
acme.com
). - Go to Edit for this new web and select Quick Install App.
- Select NodeJS and configure the following:
- Node Version: If you manage Node with NVM, a
.nvmrc
file is placed in the root of the node app with the selected version. If you installed Node without NVM, you can remove this file. - Start Script: This creates an
ecosystem.config.js
file in the root of the node app with the script you fill in (it should be the one you have in yourpackage.json
) so PM2 can manage the app. - Port: You can manage multiple apps with different ports. Assign a different port for each app you have (e.g., 3000). A
.env
file is created in the root of the node app with the selected port. If your app doesn't use this.env
file, you can remove it. - PHP Version: This field is only for HestiaCP and can be set to any value (NOT IMPORTANT).
- Node Version: If you manage Node with NVM, a
- Go to Edit Web > Advanced Options > Proxy Template > NodeJS.
- Upload your app via the file manager or clone it with Git into
/home/<user>/<domain.com>/private/nodeapp
. - 🎉 Congratulations, you're done!!!
First, change the proxy template to default, reconfigure the app using the QuickInstall, and finally change the proxy template to NodeJS.
Remove it normally. Open the file manager and delete the folder hestiacp_nodejs_config/web/<domain.com>
.