Atlantic.Net Blog

How to Install Sails.js Framework with Nginx on Oracle Linux 8

Hitesh Jethva
by Atlantic.Net (447 posts) under Dedicated Server Hosting, Tutorials
0 Comments

Sails.js is a popular, free, open-source MVC framework for Node.js. It is simple and easy to use and was developed on top of the Node.js environment. It provides developers an easier way to build custom and enterprise-grade Node.js applications. Sails.js offers a code generator that helps developers to build an application with less writing of code. With Sails.js, you can develop chat, real-time dashboards, and multiplayer games.

In this post, we will show you how to install the Salis.js framework with Nginx on Oracle Linux 8.

Prerequisites

  • A server running Oracle Linux 8 on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Oracle Linux 8 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Node.js on Oracle Linux 8

First, you will need to install Node.js on your system. To do so, first install all required dependencies using the following command:

dnf install curl gcc-c++ make -y

Next, add the Node source repo using the following command:

curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -

Next, install Node.js by running the following command:

dnf install nodejs -y

Once Node.js is installed, you can verify the Node.js version using the following command:

node --version

You will get the following output:

v18.4.0

Step 3 – Install Sails.js on Oracle Linux 8

You can use the NPM to install Sails.js easily on your system. Let’s run the following command to install Sail.js using the NPM command:

npm -g install sails

After the Sails.js installation, create a directory for the Sails.js application.

mkdir sails

Next, change the directory to the sails and create a new application using the following command:

cd sails
sails new newapp

You will be asked to select the template for your application:

 Choose a template for your new Sails app:
 1. Web App  ·  Extensible project with auth, login, & password recovery
 2. Empty    ·  An empty Sails app, yours to configure
 (type "?" for help, or <CTRL+C> to cancel)
? 1

Type 1 and press the Enter key to create your application:

 info: Installing dependencies...
Press CTRL+C to cancel.
(to skip this step in the future, use --fast)
 info: Created a new Sails app `newapp`!

Step 4 – Start Sails.js Application

After creating a Sails.js application, change the directory to your application and start the application using the command below:

cd newapp
sails lift

You will get the following output:

 info: Starting app...

 info: Initializing project hook... (`api/hooks/custom/`)
 info: Initializing `apianalytics` hook...  (requests to monitored routes will be logged!)
 info: ·• Auto-migrating...  (alter)
 info:    Hold tight, this could take a moment.
 info:  ✓ Auto-migration complete.

debug: Running v0 bootstrap script...  (looks like this is the first time the bootstrap has run on this computer)
 info: 
 info:                .-..-.
 info: 
 info:    Sails              <|    .-..-.
 info:    v1.5.2              |\
 info:                       /|.\
 info:                      / || \
 info:                    ,'  |'  \
 info:                 .-'.-==|/_--'
 info:                 `--'-------' 
 info:    __---___--___---___--___---___--___
 info:  ____---___--___---___--___---___--___-__
 info: 
 info: Server lifted in `/root/sails/newapp`
 info: To shut down Sails, press  + C at any time.
 info: Read more at https://sailsjs.com/support.

debug: -------------------------------------------------------
debug: :: Tue Jun 28 2022 11:52:10 GMT-0400 (Eastern Daylight Time)


debug: Environment : development
debug: Port        : 1337
debug: -------------------------------------------------------

Press CTRL+C to stop the application.

Step 5 – Create a Systemd Service File for Salis.js

It is a good idea to create a systemd service file to manage the Sails.js application. You can create it using the following command:

nano /lib/systemd/system/sails.service

Add the following lines:

[Unit]
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/root/sails/newapp
ExecStart=/usr/bin/sails lift
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save and close the file, then reload the systemd daemon to apply the changes:

systemctl daemon-reload

Now, start the Sails.js service and enable it to start at system reboot:

systemctl start sails
systemctl enable sails

You can also verify the status of the Sails.js service using the following command:

systemctl status sails

You will get the following output:

● sails.service
   Loaded: loaded (/usr/lib/systemd/system/sails.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-06-28 11:53:20 EDT; 6s ago
 Main PID: 18809 (node)
    Tasks: 22 (limit: 11409)
   Memory: 147.9M
   CGroup: /system.slice/sails.service
           ├─18809 node /usr/bin/sails lift
           └─18816 grunt

Jun 28 11:53:24 oraclelinux8 sails[18809]:  info:  ____---___--___---___--___---___--___-__
Jun 28 11:53:24 oraclelinux8 sails[18809]:  info:
Jun 28 11:53:24 oraclelinux8 sails[18809]:  info: Server lifted in `/root/sails/newapp`
Jun 28 11:53:24 oraclelinux8 sails[18809]:  info: To shut down Sails, press  + C at any time.
Jun 28 11:53:24 oraclelinux8 sails[18809]:  info: Read more at https://sailsjs.com/support.
Jun 28 11:53:24 oraclelinux8 sails[18809]: debug: -------------------------------------------------------
Jun 28 11:53:24 oraclelinux8 sails[18809]: debug: :: Tue Jun 28 2022 11:53:24 GMT-0400 (Eastern Daylight Time)
Jun 28 11:53:24 oraclelinux8 sails[18809]: debug: Environment : development
Jun 28 11:53:24 oraclelinux8 sails[18809]: debug: Port        : 1337
Jun 28 11:53:24 oraclelinux8 sails[18809]: debug: -------------------------------------------------------

At this point, the Sails.js application is started and listens on port 1337. You can check it using the following command:

ss -antpl | grep 1337

You will get the following output:

LISTEN 0      128                *:1337            *:*    users:(("node",pid=18809,fd=19))  

Step 6 – Configure Nginx as a Reverse Proxy for Sails.js

First, install Nginx with the following command:

dnf install nginx

Next, create an Nginx virtual host configuration file using the following command:

nano /etc/nginx/conf.d/sails.conf

Add the following lines:

server {
 listen       80;
 server_name  sails.example.com;
   location / {
     proxy_pass        http://localhost:1337/;
     proxy_set_header  Host $host;
     proxy_buffering   off;
   }
 }

Save and close the file, then edit the Nginx main configuration file:

nano /etc/nginx/nginx.conf

Define the max hash bucket size:

server_names_hash_bucket_size 64;

Next, verify Nginx for syntax errors:

nginx -t

You will get the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, restart Nginx to apply the changes:

systemctl restart nginx

Step 7 – Access Sails.js

Now, open your web browser and access the Sails.js web interface using the URL http://sails.example.com. You should see the Sails.js application on the following screen:
Sail.js dashboard

Conclusion

In this post, we explained how to install Sails.js with Nginx on Oracle Linux 8. You can now start developing your first real-time application using the Sails.js framework. Try it on dedicated hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install and Use Composer on Oracle Linux 8
How to Install Sails.js Framework with Nginx as a Reverse Proxy on Oracle Linux 8
Are Data Breaches In The Cloud Getting Better Or Worse?
How to setup HTTP Strict Transport Security (HSTS) for Apache on Oracle Linux 8
How to Install Kanban Kanboard on Oracle Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Dallas, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources