# Localhost logviewer

## System requirements

{% hint style="warning" %}
Ubuntu 20.04-22.04 is required for this tutorial.
{% endhint %}

### Download logviewer

{% hint style="warning" %}
[You must have GIT installed on your system](https://localhosting-logviewer.logs.vodka/install-git)
{% endhint %}

The first step is to download logviewer. \
This simply can be done using the following command

```
git clone https://github.com/modmail-dev/logviewer logviewer
```

## Install depencies to logviewer

The next thing we will need to do is to install the pipenv depencies to logviewer

{% hint style="warning" %}
[You must have pipenv installed](https://localhosting-logviewer.logs.vodka/install-pipenv)
{% endhint %}

First we will head into the logviewer folder by doing

```
cd logviewer
```

Once we are in the logviewer folder we will install the depencies by doing the following command

```
sudo pipenv install
```

once it is installed successfully it will say this in your terminal

![](https://4213118452-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-McJNavA7RcufSqAZPm8%2F-McJXwiAXN7On_GosFFI%2F-McJZXdzgO32NSi303-y%2Ft0ibG7.png?alt=media\&token=53b82a96-72fe-460b-817a-3e260dc3036e)

## Configuring the .env

We will now head over and start configuring our `.env`\
We will start by doing

```
nano .env
```

There you will make sure the following is inside of the `.env`

`MONGO_URI=mongodb+srv://urihere`\
`URL_PREFIX=/logs`\
`HOST=0.0.0.0`\
`PORT=80`

Now we will edit the contents of your `.env`\
a example `mongo_uri` would be`mongodb+srv://Papiersnipper:mypassword123@modmail-rdm99.mongodb.net/`

Your `URL_PREFIX` should be `/logs` so\
`URL_PREFIX=/logs`

your `HOST` has to be `0.0.0.0` unless you know what your doing. So it will be\
`HOST=0.0.0.0`

Your `PORT` would be the port you want to useto run your webapp on. Stick with `80` if you have no other webapps running on your system. \
if you do have other webapp running  change the port to something like `7777` and make a nginx configuration see&#x20;

{% hint style="info" %}
[See nginx/domain setup if u want to use a different port](https://localhosting-logviewer.logs.vodka/nginx-domain-setup)
{% endhint %}

### final .env

your final .env would like like this\
`MONGO_URI=mongodb+srv://Papiersnipper:mypassword123@modmail-rdm99.mongodb.net/`\
`URL_PREFIX=/logs`\
`HOST=0.0.0.0`\
`PORT=80`

to save your file you will do the following\
\- `ctrl+x` + `Y` + `enter`  <br>

## Starting your logviewer

Now to start your logviewer you will have to run the following command&#x20;

```
sudo pipenv run python3 app.py
```

now your logviewer should be running at\
\&#xNAN;**`http://0.0.0.0`**<br>

**Optionally** you can start your logviewer using pm2 to have it running 24/7\
first install pm2

```
sudo apt install npm -y && sudo npm i pm2 -g
```

Once pm2 is installed you can do

```
sudo pm2 start logviewer.sh --name "logviewer" && sudo pm2 save
```

{% hint style="info" %}
[See the nginx/domain setup to start using a domain](https://localhosting-logviewer.logs.vodka/nginx-domain-setup)
{% endhint %}
