How to Install n8n on Ubuntu: A Comprehensive Guide
Estimated reading time: 7 minutes
Key Takeaways
- n8n enables workflow automation without deep programming knowledge.
- Installation on Ubuntu requires SSL for secure connections.
- Utilizing PM2 ensures n8n runs continuously in the background.
- Follow the configuration steps for Nginx to manage HTTPS traffic.
Table of Contents
- What is n8n?
- Prerequisites for Installing n8n on Ubuntu
- Step 1: Update System Packages
- Step 2: Install Node.js and npm
- Step 3: Install n8n
- Step 4: Install and Configure Nginx
- Step 5: Configure n8n Environment Variables
- Step 6: Install and Configure PM2
- Conclusion
- FAQ
What is n8n?
n8n is an open-source workflow automation tool that provides a visual interface for connecting different applications and services. You can create intricate workflows by integrating APIs and using pre-built templates, making it easier to automate repetitive tasks without deep programming knowledge. This capability is particularly beneficial for startups, growing businesses, and even larger enterprises aiming to improve their operations through automation.
Prerequisites for Installing n8n on Ubuntu
Before we begin the installation process, you need to have a few essential prerequisites in place:
- A functional Ubuntu server with root or sudo access.
- A registered domain pointing to your server’s IP address (e.g., n8n.domain.xyz).
- SSL certificate and private key files for your domain to establish secure connections.
Ensuring that you have these prerequisites is crucial for a successful installation.
Step 1: Update System Packages
To start, it’s always good practice to update your system packages to the latest version. This ensures that you have the most up-to-date security patches and software versions:
sudo apt update sudo apt upgrade -y
Step 2: Install Node.js and npm
n8n requires Node.js and npm (Node Package Manager) for installation. You can install both using the following commands:
sudo apt install nodejs -y sudo apt install npm -y
After installation, verify the installation of Node.js and npm by checking their versions:
node -v npm -v
Step 3: Install n8n
With npm installed, you can now proceed to install n8n globally on your server:
npm install n8n -g
This command will download and install n8n, making it available for use across your system.
Step 4: Install and Configure Nginx
To handle HTTPS connections, you will need to set up Nginx as a reverse proxy server for n8n. Follow these steps:
- Install Nginx:
- Verify that Nginx is running:
- Create a new Nginx configuration file for n8n:
- Insert the following configuration:
- Enable the configuration:
- Test the Nginx configuration:
- Restart Nginx to apply the changes:
sudo apt install nginx -y
sudo systemctl status nginx
sudo vim /etc/nginx/sites-available/n8n.conf
server {
listen 80;
server_name n8n.domain.xyz;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name n8n.domain.xyz;
ssl_certificate /home/n8nuser/certs/cert.pem;
ssl_certificate_key /home/n8nuser/certs/key.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
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;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
sudo ln -s /etc/nginx/sites-available/n8n.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Step 5: Configure n8n Environment Variables
You will need to set some environment variables necessary for n8n’s operation. You can do this by editing your profile:
export N8N_SECURE_COOKIE=false export WEBHOOK_URL=https://n8n.domain.xyz
To make these changes permanent, you may want to add these lines to your .bashrc or .bash_profile file.
Step 6: Install and Configure PM2
PM2 is a process manager for Node.js applications that will help keep n8n running in the background. Follow these steps to install and configure PM2:
- Install PM2 globally:
- Start n8n using PM2:
- Ensure PM2 starts automatically on system boot:
- Follow the command output instructions to enable PM2 at startup:
npm install pm2 -g
pm2 start n8n
pm2 startup
sudo env PATH=$PATH:/home/n8nuser/.nvm/versions/node/v18.20.5/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u n8nuser --hp /home/n8nuser
Conclusion
Congratulations! You have successfully learned how to install n8n on Ubuntu with HTTPS enabled. This setup allows you to securely automate your workflows, connecting various applications and services efficiently. With n8n in place, you can enhance your operational efficiency, reduce manual tasks, and let your team focus on what truly matters — growing your business.
If you’re looking to integrate n8n deeply into your business systems or require assistance with workflow automation, consider leveraging our expertise. At Concept to Done, we specialize in optimizing business systems and providing robust automation solutions.
Explore our services or reach out to us for more personalized guidance! Contact us here.
FAQ
- Is n8n self-hosted free? Yes, n8n is open-source software, and you can run it for free on your servers.
- Can I run n8n on Linux? Absolutely! n8n is compatible with various Linux distributions, including Ubuntu.
- How much RAM is needed to run Ubuntu? A typical installation of Ubuntu requires at least 2GB of RAM, though 4GB or more is recommended for optimal performance.
By following this guide, you can ensure that your n8n instance runs smoothly and securely, paving the way for enhanced workflow automation across your organization.
h2, h3 {
border-bottom: 1px solid #000000 !important;
padding-bottom: 10px !important;
}
a {
color: #F78DA7 !important;
}