Links

Single Server Deployment

This is the step-by-step guide to help you set up the Backend API. Single Server Deployment is where you deploy all your APIs – Admin, Vendor and Storefront in a Single Server.

Single Server Deployment in Ubuntu

In order to begin with Single Server deployment, you need to have the prerequisites ready in the Server .
if you have not installed required prerequisite software please install now following the Prerequisites link
Now, follow the steps to begin the deployment process:
  • Step-1: To build the source code in local development machine, follow the required steps in API Setup.
  • Step-2: After building the source code in your local development machine, move entire files without src, and add-ons, node_modules, package-lock.json, your files in server will be like as shown below and dist folder also will be there.
  • Step-3: You have to edit your ENV file based on your infrastructure. please follow Environment Configuration link to edit your env file.
  • Step-4: To install Node packages use the command
npm i
  • Step -5: Change apache configuration and specify ProxyPass rules inside virtual host in 000-default.conf
$ cd /etc/apache2/sites-available/
$ sudo nano 000-default.conf
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
Note: (lite project folder path — like
http://00.000.000.00/lite/)
<Location /backend>
ProxyPass http://127.0.0.1:<API-PORT> ProxyPassReverse http://127.0.0.1:<API-PORT>
</Location>
then restart apache with below command
sudo service apache2 restart`
  • Step: 6 install pm2 globally by giving the following command
npm install [email protected] -g
Check whether you are having ecosystem.config.js in api folder. If it does not exist, then create the file and copy and paste the following code in that file
module.exports = {
apps : [
{
name: "spurt",
script: "dist/src/app.js",
instances: "max",
exec_mode: "cluster",
env: {
"PORT": 8000,
"NODE_ENV": "production"
}
}
]
}
  • Step: 7 for run Api api use pm2 command pm2 start
pm2 start
pm2 status
  • Step 7: After having followed the above steps correctly, you have successfully setup the API server. You can now open the browser and give this URL — http://<YOUR_IP_ADDRESS>/backend/apidoc and check the API Documentation.