Heretic can be installed on any server that can run Node.js. The database and caching server also require an architecture and configuration that must be supported by Mongo and Redis, but since these components are optional, the system can be run without them.
The Heretic build process was successfully tested on Debian Linux 11, macOS and Windows 11. The system can be run on a server or virtual machine with 512 MB RAM, but at least 2 GB of RAM may be required for a successful build.
Prerequisite steps to be taken before installing Heretic on the server:
When finished, you need to proceed with the installation process. You may also wish to use docker in order to run Heretic.
You will need to run Heretic web server in a daemon mode when running in production. There are many options how to achieve this depending on your operating system (systemd, init.d etc.). However, a recommended way is to use PM2, a daemon process manager that will help you manage and keep your application online.
There is a PM2 configuration file (ecosystem.config.js) which allows to run you Heretic website by running a simple command:
pm2 start
Please refer to the PM2 docs to learn some tips and tricks on how to implement additional PM2 features.
Heretic needs to run as web server in order to render modules on server-side. In development mode, Heretic may also serve static assets for you (which is not recommended in production mode), please check configuration files to disable or enable the static parameter in ./site/etc/system.js.
It's recommended to use a proxy server such as NGINX in production. The simple configuration for NGINX may look like this:
server { listen 80; server_name example.com; root /var/www/example.com/dist/public; access_log /var/www/example.com/logs/nginx_access.log; error_log /var/www/example.com/logs/nginx_error.log; location / { try_files $uri @heretic; } location @heretic { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://127.0.0.1:3001; } location /ws { proxy_pass http://127.0.0.1:3001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } gzip on; gzip_min_length 10240; gzip_comp_level 1; gzip_vary on; gzip_disable msie6; gzip_proxied expired no-cache no-store private auth; gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;}
The dist and node_modules directories may work in standalone mode. This means that it's the only directories which might be copied to the production server (no and other directories are required in order to run).
However, it's recommended to keep the file structure as-is, because that's how you may simplify your updates and website rebuilds.