linkpen

Deploying your own instance of LinkPen

Please note: This guide expects you to have at least some basic hosting knowledge.

This guide does not cover configuring or development.

Additionally, this guide only provides extremely basic Nginx configuration files that are not necessarily production ready, and assumes you already have Nginx installed and working!

This guide uses GNU nano, assuming you are editing code directly from console on a VPS or server. This guide also uses nginx as a proxy manager. This guide does not provide a production ready nginx configuration!

Prerequisites

Before you begin, ensure you have:

Installation

1. Clone the repository:

git clone https://github.com/sleepingami/linkpen.git
cd linkpen

or alternatively, if you want to clone to the current directory:

git clone https://github.com/sleepingami/linkpen.git .

2. Install dependencies:

npm install

3. Customise configuration file:

To correctly configure your instance, you must modify the global-variables.json file.

Summary


{
  "rootDomain": "http://your-domain.com",
  "hostPort": "5500",
  "siteTitle": "LinkPen",
  "discordInvite": "https://discord.gg/your-invite-link",
  "database_key": "your_database_secret_key",
  "isPublic": false
}

4. Start the server:

If you want to modify the frontend code, you can freely do so with:

npm run dev

Alternatively,

npm run start

NOTICE: After creating the first (admin) account, you will need to restart the app to see the dashboard.

We recommend using pm2 to keep your process alive.

pm2 crash course To install pm2: ```bash npm install pm2 -g ``` **PLEASE NOTE:** We do not recommend running the server in `dev` mode using pm2. Instead, run: ```bash pm2 start "npm run start" --name linkpen ``` Afterward, to ensure you can resurrect after a system reboot: ```bash pm2 save ``` To restart pm2 after a system-wide reboot, you can issue: ```bash pm2 resurrect ``` Alternatively, if you do change the source code and want pm2 to fetch the new source code with changes: ```bash pm2 restart linkpen ```

5. Nginx Configuration

Assuming you have Nginx installed and setup

Open the Nginx Configuration file (nano creates the file if it doesn’t exist):

nano /etc/nginx/sites-available/linkpen

Write out the file. Replace server_name with your root domain (no http://), and replace proxy_pass with your port (proxy_pass requires http://). We use 5500 in this example.

server {
    server_name linkpen.domain;
    listen 80;
    server_name your.domain.xyz;

    location / {
        proxy_pass http://localhost:5500;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Create symlink to sites-enabled:

sudo ln -s /etc/nginx/sites-available/linkpen /etc/nginx/sites-enabled/

Check Configuration (Nginx default healthcheck command):

nginx -t

Reload Nginx to apply updates:

systemctl reload nginx