> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Installing Sails.js on managed hosting accounts

> Learn how to install Sail.js on your web hosting account.

This article describes how to install [Sails.js](http://sailsjs.org/) on a managed hosting account. Sails.js is a web framework that enables you to quickly create Node.js applications.

## Step 1: Install Node.js and npm

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](/docs/installing-and-configuring-nodejs-on-managed-hosting).

## Step 2: Install Sails.js

After you install Node.js on your account, you are ready to install Sails. To do this, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. At the command prompt, type the following commands:

   ```bash theme={null}
   mkdir ~/lib
   cd ~/lib
   npm install sails
   ```

3. To create a symbolic link that enables you to run Sails from any directory in your account, type the following commands:

   ```bash theme={null}
   cd ~/bin
   ln -s ../lib/node_modules/sails/bin/sails.js sails
   ```

4. To confirm that Sails is installed and configured correctly, type the following command:

   ```bash theme={null}
   sails --version
   ```

   Sails displays the version number.

## Step 3: Create a Sails.js application

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:

1. At the command prompt, type the following commands:

   ```bash theme={null}
   cd ~
   sails new testProject
   ```

   This creates a new Sails application named *testProject*.

2. Type the following command:

   ```bash theme={null}
   cd testProject/config
   ```

3. 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,
   ```

   > 📘 Note
   >
   > To run Sails on a shared server, you must choose an unused port, and the port number must be between **49152** and **65535** (inclusive).

4. Save the changes to the *local.js* file, and then exit the text editor.

5. Type the following command:

   ```bash theme={null}
   cd ~/public_html
   ```

6. 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]
   ```

7. In both **RewriteRule** lines, replace ***xxxxx*** with the port you specified in the *local.js* file in step 3.

8. Save the changes to the *.htaccess* file, and then exit the text editor.

9. To start the Sails application, type the following commands:

   ```bash theme={null}
   cd ~/testProject
   nohup sails lift &
   ```

   > 📘 Note
   >
   > The *&* places the command in the background, and the *nohup* command ensures that the application continues running even if you log out of the current terminal session.

10. Use your web browser to visit your web site. If the Sails application is running, you see the Sails **A brand new app** page.

    > 👍 Tip
    >
    > * If the Sails application fails to start, the port you chose may already be in use. Check the application log or *nohup.out* file for error codes like **EADDRINUSE** that indicate the port is in use. If it is, select a different port number for your application, update the *local.js* and *.htaccess* files with the new port number, and then try again.
    >
    > * To stop a currently running Sails application, type the following command:
    >   ```
    >   pkill node
    >   ```
    >   This command immediately stops all running Node.js applications.

## More information

To view the official Sails.js documentation, please visit [http://sailsjs.org/documentation](http://sailsjs.org/documentation).

## Related articles

* [Installing and configure Node.js on managed hosting](/docs/installing-and-configuring-nodejs-on-managed-hosting)
