n8n is a workflow automation tool that allows you to connect different applications and services without having to write code. This article guides you through the process of installing n8n on a dedicated Linux server, step by step.
Prerequisites
Before starting the installation of n8n, make sure you have the following:
- A dedicated server with a Linux distribution (Ubuntu, Debian, etc.).
- Node.js version 14 or higher.
- npm (Node Package Manager).
- Docker (optional, but recommended for simplified installation).
- Root access or a user with sudo privileges.
Downloading and installing n8n
Installing Node.js and npm
To install n8n, start by installing Node.js and npm. Use the following commands:
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
This command downloads the Node.js installation script and installs it on your server. Check the installation with:
node -v
Installing n8n
Once Node.js and npm are installed, you can install n8n with the following command:
npm install n8n -g
This command installs n8n globally on your system. You can verify the installation by running:
n8n --version
Configuring n8n
Before starting n8n, you can configure a few important settings. Create a configuration file in your home directory:
mkdir ~/.n8n
nano ~/.n8n/config
Add the following lines to configure the database and port:
{ "DB_TYPE": "sqlite", "DB_SQLITE_DATABASE": "./database.sqlite", "N8N_PORT": 5678}
Save and close the file.
Starting n8n
To start n8n, run the following command:
n8n start
By default, n8n will be accessible at http://localhost:5678. You can access the user interface from your browser.
Installation via Docker
If you prefer to use Docker to install n8n, follow these steps:
Installing Docker
Install Docker on your server if you haven't already:
sudo apt-get update
sudo apt-get install -y docker.io
Check that Docker is installed correctly:
docker --version
Running n8n with Docker
To run n8n with Docker, use the following command:
docker run -it --rm \
-p 5678:5678 \
-e N8N_BASIC_AUTH_USER="" \
-e N8N_BASIC_AUTH_PASSWORD="" \
n8n
Make sure to replace <your_user> and <your_password> with secure values. This adds password protection to the n8n interface.
Securing n8n Configuration
To further secure your n8n installation, you can set up a reverse proxy, for example with Nginx. Here’s how to do it:
Installing Nginx
To install Nginx, use the following command:
sudo apt-get install nginx
Configuring Nginx
Create a configuration file for n8n in the available sites directory:
sudo nano /etc/nginx/sites-available/n8n
Add the following configuration:
server {
listen 80;
server_name your_domain.com;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo systemctl restart nginx
Conclusion
After following these steps, you will have successfully installed n8n on your Linux server. Whether you choose the direct installation or via Docker, n8n offers great flexibility for automating your workflows. Don’t forget to check the official n8n documentation to explore all the features it offers.