Fastest and Easiest Installation of N8n

link to the video 

Getting n8n up and running for your workflow automation needs can be surprisingly quick and straightforward, especially when leveraging the power of Windows Subsystem for Linux (WSL) and Docker. This guide will walk you through the process, ensuring you’re automating in no time!

Step 1: Install Ubuntu WSL

The first step to a seamless n8n installation is setting up Ubuntu within Windows Subsystem for Linux. This allows you to run a full Linux environment directly on your Windows machine, providing a robust platform for Docker.

Instructions:

  1. Enable WSL: Open PowerShell as an administrator and run the following command:

    PowerShell

     
    wsl --install
    

    This command will enable the necessary optional components, download the latest Linux kernel, set WSL 2 as the default, and install a Ubuntu distribution by default.

  2. Restart your computer when prompted.
  3. Complete Ubuntu Setup: After restarting, a console window will automatically open for Ubuntu. You’ll be asked to create a username and password for your new Linux distribution. Make sure to remember these credentials!

Step 2: Install Docker

Docker is a crucial component here, as it allows n8n to run in an isolated and portable environment. This simplifies installation, updates, and ensures consistency.

Instructions:

  1. Download Docker Desktop: Go to the official Docker website and download Docker Desktop for Windows: https://www.docker.com/products/docker-desktop
  2. Run the Installer: Double-click the downloaded installer and follow the on-screen prompts.
    • Ensure that “Use WSL 2 instead of Hyper-V (recommended)” is checked during the installation process.
  3. Start Docker Desktop: Once installed, launch Docker Desktop from your Start Menu.
  4. Confirm WSL 2 Integration: Docker Desktop should automatically detect your WSL 2 installation. You might see a prompt about enabling WSL 2 integration in the Docker Desktop settings (Settings > Resources > WSL Integration). Ensure your Ubuntu distribution is enabled there.

Step 3: Install n8n using Docker Pull

With WSL and Docker in place, installing n8n is now a single command away! We’ll use docker pull to download the n8n Docker image and then run it.

Instructions:

  1. Open your Ubuntu WSL Terminal: From your Windows Start Menu, search for “Ubuntu” and open the terminal application.
  2. Create a folder 📂  name it n8n using command mkdir <folder name > in this case would be mkdir n8n
  3. Now proceed to the n8n directory using cd n8n 
  4. create following files 
  5. link to git pull available if you like to grab it from there n8n/ at master · tauseefau/n8n or i have added the content below
  6.  Pull the n8n Docker Image and install : In the Ubuntu terminal, execute the following command to download the latest n8n Docker image:

    Bash

     
    docker-compose up -d 
    

    This may take a few moments depending on your internet connection.

  7. Run n8n: Once the image is pulled, you can start n8n with the following command. This command maps port 5678 from the Docker container to port 5678 on your local machine, allowing you to access n8n via your web browser.
     
    •  
  8. Access n8n: After running the command, you should see n8n starting up in your terminal. Open your web browser and navigate to:
    http://localhost:5678
    

    Congratulations! You should now see the n8n welcome screen, ready for you to start building your workflows.

#docker-compose.yml

volumes:
  db_storage:
  n8n_storage:

 

services:
  postgres:
    image: postgres:16
    restart: always
    environment:
      – POSTGRES_USER
      – POSTGRES_PASSWORD
      – POSTGRES_DB
      – POSTGRES_NON_ROOT_USER
      – POSTGRES_NON_ROOT_PASSWORD
    volumes:
      – db_storage:/var/lib/postgresql/data
      – ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    healthcheck:
      test: [‘CMD-SHELL’, ‘pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}’]
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      – n8n-ollama-shared

 

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    environment:
      – DB_TYPE=postgresdb
      – DB_POSTGRESDB_HOST=postgres
      – DB_POSTGRESDB_PORT=5432
      – DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      – DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
      – DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
    ports:
      – 5678:5678
    networks:
      – n8n-ollama-shared
    links:
      – postgres
    volumes:
      – n8n_storage:/home/node/.n8n
    depends_on:
      postgres:
        condition: service_healthy

 

networks:
  n8n-ollama-shared:
    external: true
#init-data.sh
#!/bin/bash
set -e;

 

# Setup for non-root user (used by n8n)
if [ -n “${POSTGRES_NON_ROOT_USER:-}” ] && [ -n “${POSTGRES_NON_ROOT_PASSWORD:-}” ]; then
  psql -v ON_ERROR_STOP=1 –username “$POSTGRES_USER” –dbname “$POSTGRES_DB” <<-EOSQL
    CREATE USER ${POSTGRES_NON_ROOT_USER} WITH PASSWORD ‘${POSTGRES_NON_ROOT_PASSWORD}’;
    GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO ${POSTGRES_NON_ROOT_USER};
    GRANT CREATE ON SCHEMA public TO ${POSTGRES_NON_ROOT_USER};
EOSQL
else
  echo “SETUP INFO: No Environment variables given for n8n user!”
fi

#.env file

POSTGRES_USER=username
POSTGRES_PASSWORD=password
POSTGRES_DB=n8ndb
POSTGRES_NON_ROOT_USER=n8n_user
POSTGRES_NON_ROOT_PASSWORD=n8npassword

Leave a Reply

Your email address will not be published. Required fields are marked *