This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| computing:librechat [2026/10/17 18:31] – oemb1905 | computing:librechat [2026/10/17 19:46] (current) – oemb1905 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Here is the converted DokuWiki-based markdown for the LibreChat setup tutorial. | + | ------------------------------------------- |
| + | * **librechat** | ||
| + | * **Jonathan Haack** | ||
| + | * **Haack' | ||
| + | * **webmaster@haacksnetworking.org** | ||
| + | ------------------------------------------- | ||
| - | ====== LibreChat Complete Setup Tutorial ====== | + | // |
| - | **Addressed to: Libre** | + | |
| - | Domain: '' | + | ------------------------------------------- |
| - | Stack: Debian 13, npm (no Docker for LibreChat), Apache reverse proxy, PM2, MongoDB 8.0, DeepInfra DeepSeek V4 Flash, custom MCP document tools (docx, xlsx, pdf, pptx). | + | |
| - | ===== 1. Prerequisites ===== | + | === Introduction |
| + | ~~NOTOC~~ | ||
| + | This is a tutorial for Debian users to setup Librechat and attach a custom API to it. I chose to use Deepinfra for cost and speed reasons, but/and used the open weight DeepSeek v4 Flash model via the Deepinfra API. I also built an MCP server to create docx, xlsx, pptx, and pdf files using python under the hood. Lastly, I used the built-in and free keenable service so that the chat could scrape websites.To begin with, let's install required dependencies, | ||
| - | < | + | < |
| sudo apt update && sudo apt upgrade -y | sudo apt update && sudo apt upgrade -y | ||
| sudo apt install -y git build-essential curl gnupg python3-pip python3-venv | sudo apt install -y git build-essential curl gnupg python3-pip python3-venv | ||
| - | </ | ||
| - | |||
| - | ==== Node.js 24 ==== | ||
| - | <code bash> | ||
| curl -fsSL https:// | curl -fsSL https:// | ||
| sudo apt install -y nodejs | sudo apt install -y nodejs | ||
| sudo npm install -g npm@11 | sudo npm install -g npm@11 | ||
| node -v && npm -v | node -v && npm -v | ||
| - | </ | ||
| - | ==== MongoDB 8.0 (Debian 13 uses Bookworm repo) ==== | ||
| - | |||
| - | <code bash> | ||
| wget -qO - https:// | wget -qO - https:// | ||
| echo "deb [ signed-by=/ | echo "deb [ signed-by=/ | ||
| Line 32: | Line 29: | ||
| sudo apt install -y mongodb-org | sudo apt install -y mongodb-org | ||
| sudo systemctl enable --now mongod | sudo systemctl enable --now mongod | ||
| - | </ | ||
| - | |||
| - | ==== PM2 ==== | ||
| - | <code bash> | ||
| sudo npm install -g pm2 | sudo npm install -g pm2 | ||
| </ | </ | ||
| - | ===== 2. Install LibreChat ===== | + | Now, let's clone the librechat repo and setup the virtual environment and the server configuration. |
| - | < | + | < |
| cd /opt | cd /opt | ||
| sudo git clone https:// | sudo git clone https:// | ||
| Line 51: | Line 44: | ||
| </ | </ | ||
| - | Essential ''.env'' | + | Email and other add-ons and other niceties and such can all be set up later to one's liking and as they see fit. The bare bones requirements are: |
| - | < | + | < |
| MONGO_URI=mongodb:// | MONGO_URI=mongodb:// | ||
| Line 67: | Line 60: | ||
| HOST=127.0.0.1 | HOST=127.0.0.1 | ||
| + | # This creates an env variable for your deepinfra key, which gets called in librechat.yaml | ||
| DEEPINFRA_API_KEY=sk-di-your_key_here | DEEPINFRA_API_KEY=sk-di-your_key_here | ||
| </ | </ | ||
| - | Generate secrets with '' | + | Use '' |
| - | < | + | < |
| npm run reinstall | npm run reinstall | ||
| - | npm run backend | + | npm run backend #test, debug, then use pm2 instead |
| pm2 start npm --name librechat -- run backend | pm2 start npm --name librechat -- run backend | ||
| pm2 save | pm2 save | ||
| - | pm2 startup | + | pm2 startup |
| </ | </ | ||
| - | ===== 3. Apache Reverse Proxy + HTTPS ===== | + | You can optionally setup a firewall: |
| - | ==== Modules ==== | + | < |
| + | sudo ufw allow OpenSSH | ||
| + | sudo ufw allow ' | ||
| + | sudo ufw enable | ||
| + | </ | ||
| + | |||
| + | |||
| + | Create or edit ''/ | ||
| + | |||
| + | < | ||
| + | |||
| + | # minimum information and parameters | ||
| + | version: 1.3.17 | ||
| + | cache: true | ||
| + | |||
| + | endpoints: | ||
| + | custom: | ||
| + | - name: " | ||
| + | apiKey: " | ||
| + | baseURL: " | ||
| + | models: | ||
| + | default: [" | ||
| + | fetch: false | ||
| + | titleConvo: true | ||
| + | titleModel: " | ||
| + | modelDisplayLabel: | ||
| + | |||
| + | # this is a built in and free in cost web scraper | ||
| + | webSearch: | ||
| + | searchProvider: | ||
| + | scraperProvider: | ||
| + | rerankerType: | ||
| + | |||
| + | # don't add this block until after initial setup and when you later create the mcp server | ||
| + | mcpServers: | ||
| + | document-tools: | ||
| + | type: stdio | ||
| + | command: / | ||
| + | args: | ||
| + | - / | ||
| + | timeout: 60000 | ||
| + | </ | ||
| + | |||
| + | pm2 restart librechat | ||
| + | |||
| + | Once librechat is running properly under pm2, the next most important step is setting up the apache reverse proxy and setting up the admin account. I just use the default apache virtual host for the domain, let apache cut and generate the cert using the non-RP vhost config, and then once the librechat service is running locally, I swap the virtual hosts with the reverse proxy versions instead and then restart the service. Here are the packages and the cert cutting commands: | ||
| - | < | + | < |
| sudo a2enmod proxy proxy_http proxy_wstunnel ssl rewrite headers socache_shmcb | sudo a2enmod proxy proxy_http proxy_wstunnel ssl rewrite headers socache_shmcb | ||
| sudo systemctl restart apache2 | sudo systemctl restart apache2 | ||
| + | sudo apt install certbot letsencrypt python3-certbot-apache | ||
| + | sudo certbot --authenticator standalone --installer apache -d chat.haacksnetworking.org --pre-hook " | ||
| </ | </ | ||
| - | ==== Certificate ==== | + | Here is your http vhost '' |
| - | < | + | < |
| - | sudo apt install -y certbot python3-certbot-apache | + | < |
| - | sudo certbot --apache -d chat.haacksnetworking.org | + | |
| + | Redirect permanent / https:// | ||
| + | </ | ||
| </ | </ | ||
| - | ==== VirtualHost ==== | + | Here is your https vhost '' |
| - | < | + | < |
| < | < | ||
| ServerName chat.haacksnetworking.org | ServerName chat.haacksnetworking.org | ||
| Line 109: | Line 152: | ||
| ProxyRequests Off | ProxyRequests Off | ||
| - | # Exclude downloads from proxy (must come before ProxyPass /) | + | # Exclude downloads from proxy - must come before ProxyPass / |
| + | # You create this down below for MCP downloads | ||
| ProxyPass /downloads ! | ProxyPass /downloads ! | ||
| Alias /downloads / | Alias /downloads / | ||
| Line 136: | Line 180: | ||
| ErrorLog ${APACHE_LOG_DIR}/ | ErrorLog ${APACHE_LOG_DIR}/ | ||
| CustomLog ${APACHE_LOG_DIR}/ | CustomLog ${APACHE_LOG_DIR}/ | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | ServerName chat.haacksnetworking.org | ||
| - | Redirect permanent / https:// | ||
| </ | </ | ||
| </ | </ | ||
| - | < | + | Once you swap the vhosts with the reverse proxy configs you enable the vhosts, check the config, and reload the latest apache2 config for the currently running service. |
| + | |||
| + | < | ||
| sudo a2ensite librechat | sudo a2ensite librechat | ||
| sudo apache2ctl configtest | sudo apache2ctl configtest | ||
| Line 150: | Line 191: | ||
| </ | </ | ||
| - | ==== Firewall ==== | + | You can now go to your domain.com in your web browser and setup your admin account. Make sure to verify it with mongodb on the backend. After setting up the account, run |
| - | < | + | < |
| - | sudo ufw allow OpenSSH | + | mongosh --quiet --eval |
| - | sudo ufw allow 'Apache Full' | + | |
| - | sudo ufw enable | + | |
| </ | </ | ||
| - | ===== 4. librechat.yaml (DeepSeek + Web Search + MCP) ===== | + | If you want to disable public registration, |
| - | Create or edit ''/ | + | < |
| - | + | ALLOW_REGISTRATION=false | |
| - | < | + | |
| - | version: 1.3.17 | + | |
| - | cache: true | + | |
| - | + | ||
| - | endpoints: | + | |
| - | custom: | + | |
| - | - name: " | + | |
| - | apiKey: " | + | |
| - | baseURL: " | + | |
| - | models: | + | |
| - | default: [" | + | |
| - | fetch: | + | |
| - | titleConvo: true | + | |
| - | titleModel: " | + | |
| - | modelDisplayLabel: | + | |
| - | + | ||
| - | webSearch: | + | |
| - | searchProvider: | + | |
| - | scraperProvider: | + | |
| - | rerankerType: | + | |
| - | + | ||
| - | mcpServers: | + | |
| - | document-tools: | + | |
| - | type: stdio | + | |
| - | command: / | + | |
| - | args: | + | |
| - | - / | + | |
| - | timeout: 60000 | + | |
| </ | </ | ||
| - | ===== 5. MCP Document-Tools Server (docx, xlsx, pdf, pptx) ===== | + | Then create users with '' |
| - | < | + | < |
| cd /opt | cd /opt | ||
| mkdir -p / | mkdir -p / | ||
| Line 203: | Line 214: | ||
| </ | </ | ||
| - | Create ''/ | + | Create ''/ |
| - | < | + | < |
| # | # | ||
| import json | import json | ||
| Line 383: | Line 394: | ||
| </ | </ | ||
| - | < | + | < |
| chmod +x / | chmod +x / | ||
| mkdir -p / | mkdir -p / | ||
| deactivate | deactivate | ||
| - | </ | ||
| - | |||
| - | Restart LibreChat: | ||
| - | |||
| - | <code bash> | ||
| pm2 restart librechat | pm2 restart librechat | ||
| </ | </ | ||
| - | ===== 6. Using the Tools ===== | + | The python above is 4 programs that do each of the various tasks of creating doc files, spreadsheets, |
| - | * In a chat, open the tools / MCP menu. | + | < |
| - | * Add or enable the **document-tools** MCP server. | + | |
| - | * Ask for a document. Available tools: | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | + | ||
| - | Example prompts: | + | |
| - | + | ||
| - | * " | + | |
| - | * "Make an Excel file named ' | + | |
| - | * " | + | |
| - | * " | + | |
| - | + | ||
| - | Files appear at '' | + | |
| - | + | ||
| - | ===== 7. Admin and Registration ===== | + | |
| - | + | ||
| - | First account is admin. Verify: | + | |
| - | + | ||
| - | < | + | |
| - | mongosh --quiet --eval 'db = db.getSiblingDB(" | + | |
| - | </ | + | |
| - | + | ||
| - | To disable public registration, | + | |
| - | + | ||
| - | <code env> | + | |
| - | ALLOW_REGISTRATION=false | + | |
| - | </ | + | |
| - | + | ||
| - | Then create users with '' | + | |
| - | + | ||
| - | ===== 8. Updates ===== | + | |
| - | + | ||
| - | <code bash> | + | |
| cd / | cd / | ||
| pm2 stop librechat | pm2 stop librechat | ||
| Line 440: | Line 411: | ||
| </ | </ | ||
| - | ===== Quick Checklist ===== | + | --- // |
| - | + | ||
| - | 1. Node 24 + MongoDB (Bookworm repo) | + | |
| - | 2. Clone → '' | + | |
| - | 3. PM2 | + | |
| - | 4. Apache modules + Certbot + VirtualHost (with '' | + | |
| - | 5. '' | + | |
| - | 6. MCP server in '' | + | |
| - | 7. Restart LibreChat and enable the document-tools MCP server in chat | + | |
| - | + | ||
| - | **This is the full working configuration.** | + | |
| - | ``` | + | |