> For the complete documentation index, see [llms.txt](https://docs.kiloiot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kiloiot.io/kilo-docs-pt/kilo-center/kilo-mioty-service-center/getting-started/installation-linux-host.md).

# Instalação: Host Linux

Instale o KiloCenter num host Linux sem Docker — PostgreSQL, Redis, Mosquitto, certificados TLS e os quatro serviços KC.

### Objetivo

Execute o KiloCenter sem Docker, instalando todas as dependências diretamente no host.

### Passo 1: Instalar Dependências de Infraestrutura

Instale e inicie estes serviços no host:

* **PostgreSQL 18+** -- criar uma base de dados chamada `kilocenter`
* **Redis 7+**
* **Mosquitto 2.0+**

### Passo 2: Gerar Certificados TLS

Compile o gerador de certificados e gere os certificados antes de configurar ou iniciar o KC-Core:

```bash
cd kilocenter-modules
go build -o KC-Core/certgen KC-Core/cmd/certgen/main.go
KC-Core/certgen -dir KC-Core/certificates -days 365 -server your-hostname.example.com
```

Substitua `your-hostname.example.com` com o FQDN ou endereço IP que as estações base usarão para alcançar este servidor. Para testes apenas locais, use `localhost`.

Isto cria quatro ficheiros em `KC-Core/certificates/`:

* `ca.crt` e `ca.key` -- certificado da CA e chave privada
* `server.crt` e `server.key` -- certificado do servidor e chave privada

O certificado do servidor inclui automaticamente `localhost`, `127.0.0.1`, e todos os IPs da rede local como SANs.

O KC-Core não conseguirá iniciar sem estes ficheiros. Para renovar mais tarde sem regenerar a CA, use `-server-only`:

```bash
KC-Core/certgen -dir KC-Core/certificates -days 365 -server your-hostname.example.com -server-only
```

Consulte Segurança para a referência completa do certgen e geração de certificados de cliente.

### Passo 3: Configurar o KC-Core

Atualize `kilocenter-modules/KC-Core/config.yaml` para corresponder aos endereços dos serviços do seu host. Definições principais:

* `storage.host` e `storage.port` -- endereço do PostgreSQL (normalmente `localhost:5432` para instalação no host)
* `storage.username` e `storage.password` -- credenciais da base de dados
* caminhos dos certificados TLS de BSSCI e SCACI

### Passo 4: Compilar e Iniciar o KC-Core

De `kilocenter-modules/KC-Core/`:

```bash
go build -o kilocenter ./cmd/kilocenter/
./kilocenter -config config.yaml
```

### Passo 5: Compilar e Iniciar o KC-Gateway

De `kilocenter-modules/KC-Gateway/`:

```bash
go build -o gateway ./cmd/gateway/
./gateway -config config.yaml
```

### Passo 6: Iniciar o KC-Web

De `kilocenter-modules/KC-Web/`:

```bash
bun install
bun run dev
```

### Passo 7: Validar

* saúde do KC-Core: <http://localhost:8086/health>
* Estado de saúde do KC-Gateway: <http://localhost:8087/health>
* KC-Web: <http://localhost:5173>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kiloiot.io/kilo-docs-pt/kilo-center/kilo-mioty-service-center/getting-started/installation-linux-host.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
