Sails.js is a powerful MVC framework for Node.js that makes it easy to build custom, enterprise-grade Node.js applications. In this guide, we will walk through the steps to install Sails.js on Debian 11 and configure it to run behind Nginx.
Step 1: Update Your System
Start by ensuring your system is up to date:
sudo apt update && sudo apt upgrade -y
Step 2: Install Node.js and npm
Sails.js requires Node.js and npm (Node Package Manager). You can install them using the following commands:
sudo apt install -y nodejs npm
Step 3: Install Sails.js
Once Node.js and npm are installed, you can install Sails.js globally:
sudo npm install -g sails
Step 4: Create a New Sails.js Application
Create a new Sails.js project by running:
sails new mySailsApp
Navigate to your newly created project directory:
cd mySailsApp
Step 5: Configure the Application
Before starting the application, configure your Sails.js app by editing the config/env/production.js
file to set the appropriate environment settings:
nano config/env/production.js
Make sure to configure the necessary database settings and other production configurations.
Step 6: Start the Sails.js Application
You can start your Sails.js application using:
sails lift
Your application should now be running on port 1337 by default.
Step 7: Install and Configure Nginx
Install Nginx if you haven't done so already:
sudo apt install -y nginx
Create a new Nginx configuration file for your Sails.js app:
sudo nano /etc/nginx/sites-available/sails.conf
Add the following configuration:
server {
listen 80;
server_name your_domain.com; # Replace with your domain
location / {
proxy_pass http://localhost:1337; # Sails.js runs on port 1337
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Replace your_domain.com
with your actual domain name.
Step 8: Enable the Nginx Configuration
Enable the new configuration by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/sails.conf /etc/nginx/sites-enabled/
Step 9: Restart Nginx
Restart Nginx to apply the changes:
sudo systemctl restart nginx
Step 10: Access Your Sails.js Application
Now you can access your Sails.js application by navigating to:
http://your_domain.com
Conclusion
You have successfully installed the Sails.js MVC framework and configured it to run behind Nginx on Debian 11. This setup provides a robust foundation for building web applications.
If you're looking for a reliable hosting solution for your Sails.js application, consider using Windows VPS UK. With Windows VPS, you can efficiently host your applications and ensure high performance. Whether you need VPS UK Windows or Windows Virtual Private Servers, you'll find a solution that fits your requirements.
For larger deployments or enterprise needs, explore Windows Virtual Dedicated Server Hosting or Virtual Private Server Hosting Windows. Whether you're located in the UK, Italy, or elsewhere, Windows VPS Italy and UK VPS Windows offer reliable hosting options. Visit Windows VPS Hosting UK to discover the best hosting solutions for your development needs.