Skip to main content

Server Configuration

This is mostly basic Linux server configuration stuff but I felt it important to document and share the steps I took to get Verdaccio running permanently on my server. You will need root (or sudo) permissions for the following steps.

Pokretanje, kao zaseban korisnik

Najpre kreirajte verdaccio korisnika:

$ sudo adduser --system --gecos 'Verdaccio NPM mirror' --group --home /var/lib/verdaccio verdaccio

U slučaju da nemate postojećeg korisnika potrebno je da ga dodate, adduser:

$ sudo useradd --system --comment 'Verdaccio NPM mirror' --create-home --home-dir /var/lib/verdaccio --shell /sbin/nologin verdaccio

Zatim kreirate shell kao verdaccio korisnik, putem sledeće komande:

$ sudo su -s /bin/bash verdaccio
$ cd

The cd command sends you to the home directory of the Verdaccio user. Make sure you run Verdaccio at least once to generate the config file. Edit it according to your needs.

Listening na svim adresama

Ako želite da osluškujete (listen to) svaku eksternu adresu, podesite listen direktivu na:

# možete podesiti listen address (ili port)
listen: 0.0.0.0:4873

Ako imate pokrenut verdaccio u Amazon EC2 instanci, moraćete da podesite listen u change your config file kao što je prikazano u navedenom primeru.

Configure Apache or nginx? Please check out the Reverse Proxy Setup

Kako da verdaccio radi neprekidno

Možete da koristite node package zvani 'forever' kako biste imali verdaccio koji će neprekidno raditi.

Prvo instalirajte forever globalno:

$ sudo npm install -g forever

Make sure you've run Verdaccio at least once to generate the config file and write down the created admin user. You can then use the following command to start Verdaccio:

$ forever start `which verdaccio`

Možete pogledati dokumentaciju za više informacija o tome kako da koristite paket forever.

Preživljavanje resetovanja servera

You can use crontab and forever together to start Verdaccio after a server reboot.

When you're logged in as the Verdaccio user do the following:

$ crontab -e

This might ask you to choose an editor. Pick your favorite and proceed. Add the following entry to the file:

@reboot /usr/bin/forever start /usr/lib/node_modules/verdaccio/bin/verdaccio

The locations may vary depending on your server setup. If you want to know where your files are you can use the 'which' command:

$ which forever
$ which verdaccio

Using systemd

Instead of forever you can use systemd for starting Verdaccio and keeping it running. Verdaccio installation has systemd unit, you only need to copy it:

$ sudo cp /usr/lib/node_modules/verdaccio/systemd/verdaccio.service /lib/systemd/system/ && sudo systemctl daemon-reload

This unit assumes you have configuration in /etc/verdaccio/config.yaml and store data in /var/lib/verdaccio, so either move your files to those locations or edit the unit.