Running from Node.js¶
Install and run Silex from npm, source code, or npx for development and self-hosted setups.
Overview¶
Instead of Docker, you can run Silex directly on your server using Node.js. This gives you more control over the process manager (systemd, PM2, supervisor) and lets you customize the startup script.
Three installation methods:
- npm package — Recommended for deployment
- npx — Quick testing without installation
- Source code — For development and contributing
Prerequisites¶
- Node.js 18 or later
- npm 8 or later (comes with Node)
- Git (if cloning from source)
Setup from npm¶
1. Install globally or locally¶
Global install:
Or per-project:
2. Create .env file¶
cat > .env << EOF
SILEX_SESSION_SECRET=$(openssl rand -base64 32)
SILEX_PORT=6805
SILEX_URL=http://localhost:6805
STORAGE_CONNECTORS=fs
HOSTING_CONNECTORS=fs,download
SILEX_FS_ROOT=./silex/storage
SILEX_FS_HOSTING_ROOT=./silex/hosting
EOF
3. Start the server¶
With global install:
With local install:
Or add to package.json:
Then run:
The server starts at the URL in your .env file (default: http://localhost:6805).
Quick test with npx¶
No installation needed:
This downloads, installs, and runs the latest version. The server listens on port 6805 by default.
Stop with Ctrl+C. All data is stored in ./silex/storage and ./silex/hosting in your current directory.
Setup from source code¶
For development or building plugins:
Run the dev server:
Or run from the monorepo root:
Want to contribute? After cloning, check GitHub Issues for beginner-friendly tasks. See also Contribute to Silex.
Environment variables¶
All variables can be set in a .env file or passed as command-line arguments:
See docker.md#environment-variables for the full list.
Key variables for Node setup:
| Variable | Default | Purpose |
|---|---|---|
SILEX_PORT |
6805 | Port to listen on |
SILEX_HOST |
localhost | Hostname (0.0.0.0 for remote access) |
SILEX_URL |
http://localhost:6805 | Public URL users visit |
SILEX_SESSION_SECRET |
(none) | Random key for session encryption |
SILEX_SERVER_CONFIG |
.silex.js | Path to config file (relative to cwd) |
SILEX_CLIENT_CONFIG |
client-config.js | Path to client config file |
Setting SILEX_HOST for remote access¶
By default, the server only listens on localhost. To allow remote connections:
Then access from another machine: http://your-server-ip:6805
Running as a system service¶
With systemd (Linux)¶
Create /etc/systemd/system/silex.service:
[Unit]
Description=Silex Website Builder
After=network.target
[Service]
Type=simple
User=silex
WorkingDirectory=/home/silex/silex-instance
ExecStart=/usr/bin/node /usr/bin/silex-platform
Restart=on-failure
RestartSec=10
# Environment
Environment="SILEX_PORT=6805"
Environment="SILEX_URL=https://silex.example.com"
Environment="SILEX_SESSION_SECRET=your-random-secret"
[Install]
WantedBy=multi-user.target
Create the silex user:
sudo useradd -m -s /usr/sbin/nologin silex
sudo mkdir -p /home/silex/silex-instance
sudo chown silex:silex /home/silex/silex-instance
Enable and start:
Check status:
With PM2¶
Install PM2:
Create ecosystem.config.js in your Silex instance directory:
module.exports = {
apps: [
{
name: 'silex',
script: 'silex-platform',
instances: 1,
exec_mode: 'cluster',
env: {
SILEX_PORT: 6805,
SILEX_URL: 'https://silex.example.com',
SILEX_SESSION_SECRET: 'your-random-secret',
STORAGE_CONNECTORS: 'fs',
HOSTING_CONNECTORS: 'fs,download',
},
},
],
}
Start:
View logs:
Custom server config¶
You can modify server behavior with a config file:
Create my-config.js:
const GitlabConnector = require('@silexlabs/silex-plugins').GitlabConnector
module.exports = async function (config) {
// Add a storage connector
config.addStorageConnector(
new GitlabConnector(config, {
clientId: process.env.GITLAB_CLIENT_ID,
clientSecret: process.env.GITLAB_CLIENT_SECRET,
domain: process.env.GITLAB_DOMAIN,
})
)
}
See Server configuration for the full ServerConfig API.
Debugging¶
Enable debug mode:
This reloads the config file on each request and logs detailed startup info.
Troubleshooting¶
Port already in use¶
Change the port:
Or find and kill the process using port 6805:
EACCES permission denied¶
npm tried to install globally without sudo. Fix npm permissions:
Then add to your shell profile (.bashrc, .zshrc):
Module not found errors¶
Reinstall dependencies:
See also¶
- Docker Compose setup
- Managed hosting platforms
- Server configuration — Config file API