2021-07-11 08:42:56 -05:00
---
id: aws
2022-12-25 12:48:18 -05:00
title: 'Amazon Web Services'
2021-07-11 08:42:56 -05:00
---
This document describes simple steps to setup Verdaccio private registry on Amazon Web Services platform using EC2 service. This assumes you have already created an EC2 Amazon Linux instance; if not then please check this tutorial on [AWS EC2 Setup ](https://www.howtoinmagento.com/2018/04/aws-cli-commands-for-aws-ec2-amazon.html ).
2021-07-27 14:52:49 -05:00
## Setup & Configuration {#setup--configuration}
2021-07-11 08:42:56 -05:00
**Step 1:** Open SSH & Login in using your EC2 key.
2021-12-01 11:20:13 -05:00
**Step 2:** Install Node Version Manager (nvm) first, close and re-open the SSH using your EC2 key.
2021-07-11 08:42:56 -05:00
2022-12-25 12:48:18 -05:00
`sudo apt update`
`wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash`
`exit`
2021-07-11 08:42:56 -05:00
**Step 3:** Install Node using Node Version Manager (nvm)
2022-12-25 12:48:18 -05:00
`nvm install node`
2021-07-11 08:42:56 -05:00
**Step 4:** Install Verdaccio & pm2, will require to run Verdaccio service in background
2022-12-25 12:48:18 -05:00
`npm i -g verdaccio pm2`
2021-07-11 08:42:56 -05:00
**Step 5:** Set the verdaccio registry as a source. By default original NPM registry set.
2022-12-25 12:48:18 -05:00
`npm set registry http://localhost:4873`
`npm set ca null`
2021-07-11 08:42:56 -05:00
2021-12-01 11:20:13 -05:00
**Step 6:** Run Verdaccio and stop it (ctrl+c). It will create a config file we will use.
2021-07-11 08:42:56 -05:00
2022-12-25 12:48:18 -05:00
`verdaccio`
2021-07-11 08:42:56 -05:00
**Step 7:** Now do below configuration for listening to all addresses on that server machine / EC2 instance. [(read more) ](https://github.com/verdaccio/verdaccio/blob/master/conf/full.yaml )
Open and edit `config.yaml` file:
2022-12-25 12:48:18 -05:00
` nano .config/verdaccio/config.yaml` or ` nano ~/verdaccio/config.yaml`
2021-07-11 08:42:56 -05:00
Add below lines at the end. [(read more) ](https://github.com/verdaccio/verdaccio/blob/ff409ab7c05542a152100e3bc39cfadb36a8a080/conf/full.yaml#L113 )
2022-12-25 12:48:18 -05:00
```
listen:
- 0.0.0.0:4873
2021-07-11 08:42:56 -05:00
```
Change below line so that only authenticated person can access our registry
2022-12-25 12:48:18 -05:00
`Replace "access: $all" with "access: $authenticated"`
(Optional) Change below line according to how many users you wish to grant access to the scoped registry
`Replace "#max_users: 1000" with "max_users: 1"`
2021-07-11 08:42:56 -05:00
There are some more parameters available to configure it. Like storage, proxy, default port change. [(read more) ](https://github.com/verdaccio/verdaccio/blob/ff409ab7c05542a152100e3bc39cfadb36a8a080/conf/full.yaml#L113 )
**Step 8:** Run Verdaccio in background using PM2:
2022-12-25 12:48:18 -05:00
`pm2 start verdaccio`
2021-07-11 08:42:56 -05:00
**Step 9:** Now, You can access your Verdaccio web UI.
The URL will look like something:
2022-12-25 12:48:18 -05:00
`http://ec2-..compute.amazonaws.com:4873`
2021-07-11 08:42:56 -05:00
{or}
2022-12-25 12:48:18 -05:00
`http://your-ec2-public-ip-address:4873 (You can check your EC2 instance public ip from AWS console)`
2021-07-11 08:42:56 -05:00
To confirm Verdaccio's running status, run the command below:
2022-12-25 12:48:18 -05:00
` pm2 list`
To make Verdaccio launch on startup, run the commands below:
`pm2 stop verdaccio`
`pm2 delete verdaccio`
`pm2 startup` This will show a command in your terminal. Copy / paste it and execute it to have pm2 make a startup service for you.
`which verdaccio` Copy the path shown by this command.
`pm2 start /home/ubuntu/.nvm/versions/node/v17.1.0/bin/verdaccio` (put the path you copied from command above).
`pm2 status` This should show "online" on the status of verdaccio service.
`pm2 save` Now when you reboot the EC2 instance, it should launch verdaccio.
2021-07-11 08:42:56 -05:00
**Step 10:** Registering a user in verdaccio registry
2022-12-25 12:48:18 -05:00
` npm adduser`
2021-07-11 08:42:56 -05:00
2022-12-25 12:48:18 -05:00
It will ask for username, password and valid email id to be entered. Make a note of this details that will use later to login in verdaccio registry to publish our library.
2021-07-11 08:42:56 -05:00
**Step 11:** Now we are ready to use our AWS server instance work as a private registry.
Login into verdaccio registry. Enter the same username, password and email id set in above Step.
2022-12-25 12:48:18 -05:00
` npm set registry http://your-ec2-public-ip-address:4873`
` npm login`
2021-07-11 08:42:56 -05:00
**Step 12:** Go to your custom library package path. In my case this is my Angular 7 package path -> `/libraries/dist/your-library-name/your-library-name-0.0.1.tgz`
If you like to know how to create angular 7 library/package then [(click here) ](https://www.howtoinmagento.com/2019/11/how-to-create-your-first-angular-7.html )
2022-12-25 12:48:18 -05:00
` cd [custom library package path]`
2021-07-11 08:42:56 -05:00
**Step 13:** Finally publish our library `your-library-name-0.0.1.tgz` on verdaccio registry
2022-12-25 12:48:18 -05:00
` [custom library package path] >> npm publish your-library-name-0.0.1.tgz`
2021-07-11 08:42:56 -05:00
{or}
2022-12-25 12:48:18 -05:00
` [custom library package path] >> npm publish`
2021-07-11 08:42:56 -05:00
{or}
2022-12-25 12:48:18 -05:00
` [custom library package path] >> npm publish --registry http://your-ec2-public-ip-address:4873`
2021-07-11 08:42:56 -05:00
2022-12-25 12:48:18 -05:00
Now browse ` http://your-ec2-public-ip-address:4873` and you will see new library package there.