22/02/2024 20:01 Install n8n - Open Source Workflow Automation - on Linux
▲A A▼
Install n8n - Open Source Workflow Automation - on Linux
What is n8n?
n8n is an extendable workflow automation tool. With a fair-code distribution model, n8n will always have visible source code, be
available to self-host, and allow you to add your own custom functions, logic and apps. n8n's node-based approach makes it highly
versatile, enabling you to connect anything to everything. -https://github.com/n8n-io/n8n
Installing n8n
1. ✓ Log into the Linux device
2. Run the following commands in a terminal window
# update software repositories
sudo apt update
# install available software updates
sudo apt upgrade -y
# add nodejs software repository
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
# install nodejs
sudo apt install nodejs -y
# install mariadb
sudo apt install mariadb-server mariadb-client -y
# configure the MySQL database
sudo su
mysql_secure_installation
3. Press Enter to login as root
4. Type N and press Enter to not switch to unix socket authentication
5. Type Y and press Enter to set a root password, type the password twice to confirm
6. Type Y and press Enter to remove anonymous users
https://i12bretro.github.io/tutorials/0784.html 1/4
22/02/2024 20:01 Install n8n - Open Source Workflow Automation - on Linux
7. Type Y and press Enter to disallow root login remotely
8. Type Y and press Enter to remove the test database
9. Type Y and press Enter to reload privilege tables
10. Run the following command to login into MySQL:
mysql -u root -p
11. Authenticate with the root password set earlier
12. Run the following commands to create the n8n database and database user
CREATE DATABASE n8n;
GRANT ALL ON n8n.* to 'n8n_rw'@'localhost' IDENTIFIED BY 'n8n_N8N!';
FLUSH PRIVILEGES;
EXIT;
exit
13. Continue with the following commands:
# set environmental variables
export DB_TYPE="mysqldb"
export DB_MYSQLDB_DATABASE="n8n"
export DB_MYSQLDB_HOST="localhost"
export DB_MYSQLDB_USER="n8n_rw"
export DB_MYSQLDB_PASSWORD="n8n_N8N!"
export GENERIC_TIMEZONE="America/New_York"
# install n8n
sudo npm install n8n --location=global
# audit and fix vulnerabilities
sudo npm audit fix
# run n8n
n8n
14. Open a web browser and navigate to http://DNSorIP:5678
15. Complete the form with an email, first name, last name and password > Click next
16. Complete the questionnaire > Click continue
https://i12bretro.github.io/tutorials/0784.html 2/4
22/02/2024 20:01 Install n8n - Open Source Workflow Automation - on Linux
17. Click Get started
18. Welcome to n8n
Running n8n as a Service
1. Press CTRL+C to end the running n8n process
2. Continue with the following commands
# create n8n service file
sudo nano /etc/systemd/system/n8n.service
3. Paste the following configuration into n8n.service
[Unit]
Description=n8n
After=mariadb.service
[Service]
User=root
Group=root
Environment=DB_TYPE=mysqldb
Environment=DB_MYSQLDB_DATABASE=n8n
Environment=DB_MYSQLDB_HOST=localhost
Environment=DB_MYSQLDB_USER=n8n_rw
Environment=DB_MYSQLDB_PASSWORD=n8n_N8N!
Environment=GENERIC_TIMEZONE=America/New_York
ExecStart=n8n
WorkingDirectory=/usr/bin
[Install]
WantedBy=multi-user.target
4. Press CTRL+O, Enter, CTRL+X to write the changes
https://i12bretro.github.io/tutorials/0784.html 3/4
22/02/2024 20:01 Install n8n - Open Source Workflow Automation - on Linux
5. Continue with the following commands
# reload systemd services
sudo systemctl daemon-reload
# start n8n service on boot and now
sudo systemctl enable n8n --now
6. Back in the web browser, refresh n8n to verify it is now running a service
7. Log in using the email address and password setup earlier
Source: https://docs.n8n.io/hosting/installation/npm/
https://i12bretro.github.io/tutorials/0784.html 4/4