# VPS Setup

{% embed url="<https://youtu.be/objpAGzFlgM?t=219>" fullWidth="true" %}
SunLicense Server Setup VPS Guide (Without Pterodactyl)
{% endembed %}

## SunLicense VPS Setup Guide (Without Pterodactyl)

This guide will walk you through setting up SunLicense on a VPS without using Pterodactyl.

### Prerequisites

Before starting, ensure your VPS meets the following requirements:

* **Java 21+ installed**
* **A valid SunLicense license key**

### Installation Steps

#### 1. Upload Required Files

Transfer the following files to your VPS:

* `server.jar` (SunLicense server file)
* `license.txt` (Contains your license key)

You can use `scp` or an FTP client like FileZilla to upload these files to your VPS.

Example using `scp`:

```sh
scp server.jar license.txt user@your-vps-ip:/home/user/
```

#### 2. Start SunLicense Server

Navigate to the directory containing `server.jar` and `license.txt`, then execute the following command:

```sh
SERVER_PORT=25595 java -Dterminal.jline=false -Dterminal.ansi=true -jar server.jar
```

* Replace `25595` with the desired port number.
* Ensure the port is open in your firewall settings.

If Java 21+ is not installed, you can install it using:

```sh
sudo apt update
sudo apt install openjdk-21-jdk -y
```

#### 3. Verify Local Access

Once the server starts, you can access SunLicense from the VPS itself:

```sh
curl http://localhost:25595
```

Replace `25595` with your chosen port.

#### 4. Expose to the Internet (Optional)

If you want to access SunLicense from an external network, you need to configure a reverse proxy using Nginx.

**Install Nginx**

```sh
sudo apt install nginx -y
```

**Configure Nginx Proxy**

Create a new Nginx configuration file:

```sh
sudo nano /etc/nginx/sites-available/sunlicense
```

Add the following content:

```nginx
server {
    listen 80;
    server_name yourdomain.com;

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

Save and exit (`CTRL + X`, then `Y`, then `Enter`).

**Enable the Configuration**

```sh
sudo ln -s /etc/nginx/sites-available/sunlicense /etc/nginx/sites-enabled/
```

Restart Nginx:

```sh
sudo systemctl restart nginx
```

Now, you can access SunLicense from `http://yourdomain.com`.

#### 5. Running on Port 80 (Alternative)

If you don't want to use Nginx, you can run SunLicense directly on port 80:

```sh
SERVER_PORT=80 java -Dterminal.jline=false -Dterminal.ansi=true -jar server.jar
```

> **Note:** This works only if no other services (like Nginx or Apache) are using port 80.

#### 6. Configure Firewall (If Required)

To allow external access, open the required ports:

```sh
sudo ufw allow 80/tcp
sudo ufw allow 25595/tcp
sudo ufw reload
```

#### 7. Keeping SunLicense Running

To keep SunLicense running even after closing the terminal, use `screen` or `tmux`:

**Using `screen`**

```sh
sudo apt install screen -y
screen -S sunlicense
SERVER_PORT=25595 java -Dterminal.jline=false -Dterminal.ansi=true -jar server.jar
```

Press `CTRL + A`, then `D` to detach. To resume, use:

```sh
screen -r sunlicense
```

**Using `tmux`**

```sh
sudo apt install tmux -y
tmux new -s sunlicense
SERVER_PORT=25595 java -Dterminal.jline=false -Dterminal.ansi=true -jar server.jar
```

Detach with `CTRL + B`, then `D`. Resume with:

```sh
tmux attach -t sunlicense
```

### Conclusion

SunLicense is now set up on your VPS without Pterodactyl. You can manage it manually or configure a systemd service for automatic startup. If you need a managed setup, consider [SunLicense Managed Hosting](https://docs.sunlicense.hapangama.com/services/managed-hosting).

For purchasing, visit: [SunLicense on BuiltByBit](https://builtbybit.com/resources/sunlicense-license-management-system.58359/).
