This article describes how to install Sails.js on a managed hosting account. Sails.js is a web framework that enables you to quickly create Node.js applications.
Sails.js runs on top of Node.js, so the first step is to install Node.js and npm (the Node.js package manager) on your account. For step-by-step instructions about how to do this, please see this article.
After you install Node.js on your account, you are ready to install Sails. To do this, follow these steps:
mkdir ~/lib cd ~/lib npm install sails
To create a symbolic link that enables you to run Sails from any directory in your account, type the following commands:
cd ~/bin ln -s ../lib/node_modules/sails/bin/sails.js sails
To confirm that Sails is installed and configured correctly, type the following command:
sails --version
Sails displays the version number.
After you install Sails, you are ready to create a Sails.js application and integrate it with the web server. To do this, follow these steps:
cd ~ sails new testProject
This creates a new Sails application named testProject.
Type the following command:
cd testProject/config
Open the local.js file in your preferred text editor. Locate the following line:
// port: process.env.PORT || 1337,
Just after that line, add the following line, replacing xxxxx with the port on which the Sails application should run:
port: xxxxx,
Type the following command:
cd ~/public_html
In your preferred text editor, create an .htaccess file and add the following lines:
RewriteEngine On RewriteRule ^$ http://127.0.0.1:xxxxx/ [P,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ http://127.0.0.1:xxxxxx/$1 [P,L]
To start the Sails application, type the following commands:
cd ~/testProject nohup sails lift &
Use your web browser to visit your web site. If the Sails application is running, you see the Sails A brand new app page.
pkill node
This command immediately stops all running Node.js applications.
To view the official Sails.js documentation, please visit http://sailsjs.org/documentation.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.