2017-12-16 13:25:59 +01:00
---
id: server-configuration
date: '2017-07-10T23:36:56.503Z'
title: "Server Configuration"
---
2017-06-24 10:11:08 +02:00
2016-08-20 18:46:54 +02:00
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.
2013-11-19 11:53:53 +01:00
## Running as a separate user
2016-08-20 18:46:54 +02:00
First create the verdaccio user:
2017-06-24 10:11:08 +02:00
2013-11-19 11:53:53 +01:00
```bash
2016-08-20 18:46:54 +02:00
$ sudo adduser --disabled-login --gecos 'Verdaccio NPM mirror' verdaccio
2013-11-19 11:53:53 +01:00
```
2016-08-20 18:46:54 +02:00
You create a shell as the verdaccio user using the following command:
2017-06-24 10:11:08 +02:00
2013-11-19 11:53:53 +01:00
```bash
2016-08-20 18:46:54 +02:00
$ sudo su verdaccio
2013-11-19 11:53:53 +01:00
$ cd ~
```
2016-08-20 18:46:54 +02:00
The 'cd ~' command send 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.
2013-11-19 11:53:53 +01:00
2013-11-19 13:26:32 +01:00
## Listening on all addresses
If you want to listen to every external address set the listen directive in the config to:
2017-06-24 10:11:08 +02:00
2017-04-19 12:21:47 +02:00
```yaml
2013-11-19 13:26:32 +01:00
# you can specify listen address (or simply a port)
listen: 0.0.0.0:4873
```
2017-09-08 08:11:27 +02:00
If you are running `verdaccio` in a Amazon EC2 Instance, [you will need set the listen in change your config file ](https://github.com/verdaccio/verdaccio/issues/314#issuecomment-327852203 ) as is described above.
2013-11-19 13:26:32 +01:00
2017-09-08 08:11:27 +02:00
> Apache configure? Please check out the [Reverse Proxy Setup](reverse-proxy.md)
2017-04-19 12:21:47 +02:00
2016-08-20 18:46:54 +02:00
## Keeping verdaccio running forever
We can use the node package called 'forever' to keep verdaccio running all the time.
2013-11-19 11:53:53 +01:00
https://github.com/nodejitsu/forever
First install forever globally:
2017-06-24 10:11:08 +02:00
2013-11-19 11:53:53 +01:00
```bash
$ sudo npm install -g forever
```
2016-08-20 18:46:54 +02:00
Make sure you've started 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:
2017-06-24 10:11:08 +02:00
2013-11-19 11:53:53 +01:00
```bash
2016-08-20 18:46:54 +02:00
$ forever start `which verdaccio`
2013-11-19 11:53:53 +01:00
```
You can check the documentation for more information on how to use forever.
## Surviving server restarts
2016-08-20 18:46:54 +02:00
We can use crontab and forever together to restart verdaccio after a server reboot.
When you're logged in as the verdaccio user do the following:
2013-11-19 11:53:53 +01:00
```bash
$ crontab -e
```
This might ask you to choose an editor. Pick your favorite and proceed.
Add the following entry to the file:
2017-06-24 10:11:08 +02:00
2013-11-19 11:53:53 +01:00
```
2016-08-20 18:46:54 +02:00
@reboot /usr/bin/forever start /usr/lib/node_modules/verdaccio/bin/verdaccio
2013-11-19 11:53:53 +01:00
```
The locations may vary depending on your server setup. If you want to know where your files are you can use the 'which' command:
2017-06-24 10:11:08 +02:00
2013-11-19 11:53:53 +01:00
```bash
$ which forever
2016-08-20 18:46:54 +02:00
$ which verdaccio
```
2017-05-20 19:44:41 +02:00
2017-06-24 10:11:08 +02:00