Manual setup
Operating System
Please do not use an OctoPi image, as it can cause unforeseen (avoidable) problems.
Please check and modify the username, if you do not use the user pi, you have to replace it in each path and in the variable User in the service files.
It is recommended to use a clean Raspberry Pi OS 64-bit Lite image. If you don't use a Raspberry Pi as SBC, every default Debian Bullseye / Bookworm (recommended) should also fit with this guide.
We recommend you follow the Raspberry Pi OS official documentation to flash and install the operating system to your SD card.
Once you have finished the installation and are connected via SSH, you can continue.
Requirements
Install the required packages and update the system:
sudo apt update && sudo apt upgrade -y
sudo apt install git unzipsudo apt update && sudo apt upgrade -y
sudo apt install git unzipsudo apt update --allow-releaseinfo-change && sudo apt upgrade --yes
sudo apt install git unzipKlipper
Installation
At first we have to install some OS dependencies:
The following commands will clone Klipper to an appropriate directory in HOME.
Then we can initialize the python virtual environment and install the python dependencies:
Configuration & startup service
After Klipper is installed, you will need to create the file structure for Klipper & Moonraker.
To create a service file for Klipper use:
fill in these lines:
Save the file with CTRL+O and close the editor with CTRL+X.
Next step, you have to create an Klipper environment file in your printer_data:
fill in these line:
Save the file with CTRL+O and close the editor with CTRL+X.
To enable and start the Klipper service execute these commands:
After your config is in place, restart Klipper with sudo systemctl start klipper.
Moonraker
Moonraker is a web server that exposes APIs which lets Mainsail interact with Klipper.
Installation
At first we have to install some OS dependencies:
Clone Moonraker into your HOME directory:
Then we can initialize the python virtual environment and install the python dependencies:
Configuration
Please pay attention to the following steps!
A very common source of errors are improperly configured trusted_clients.
For Moonraker you’ll need to create a separate config file.
Insert the following part:
Trusted Clients - read carefully
A list of newline separated IP addresses and/or IP ranges that are trusted. Trusted clients are given full access to the API. Both IPv4 and IPv6 addresses and ranges are supported. Ranges must be expressed in CIDR notation (see CIDR for more info).
For example, an entry of 192.168.1.0/24 will authorize IP addresses in the range of 192.168.1.1 - 192.168.1.254. Note that when specifying IPv4 ranges the last segment of the IP address must be 0. The default is no clients or ranges are trusted.
Save the file with CTRL+O and close the editor with CTRL+X.
Startup service
To edit this file type:
fill in these lines:
Save the file with CTRL+O and close the editor with CTRL+X.
Next step, you have to create an Klipper environment file in your printer_data:
fill in these lines:
Save the file with CTRL+O and close the editor with CTRL+X.
To enable Moonraker service execute these commands:
Then we have also to add some Moonraker PolicyKit rules. Moonraker already provides a script for these:
After your config is in place, start Moonraker with sudo systemctl start moonraker.
Open the following URL with your printers IP in your browser
If everything has been set up successfully, a message like this should appear:
Mainsail
Install web server & reverse proxy (NGINX)
NGINX is important to mount all components on port 80 and host the static files from Mainsail. To install NGINX you only need to execute:
now we create the config files with:
Each file can be filled with the following content:
Save the file with CTRL+O and close the editor with CTRL+X.
Save the file with CTRL+O and close the editor with CTRL+X.
Save the file with CTRL+O and close the editor with CTRL+X.
Create the directory for static files and active NGINX config:
Now you can recheck the API to see if it works with the reverse proxy. Open the URL http://<printer-ip>/server/info in your browser. If you see content like this:
Now we can install Mainsail.
Install httpdocs
httpdocsNow you can download the current Mainsail static data.
Now it should be possible to open the interface: http://<printer-ip>/.
With Debian 12 (Bookworm) you have to add the correct user rights. Execute these lines to add the www-data user to the pi group and set executeable rights to the home directory:
Change the username pi, if you changed it or use a different default username.
Important macros
If you want the whole experience with Mainsail and Klipper virtual_sdcard print, you should use these macros or use them as templates for your own.
Use hostname instead of IP to open Mainsail (optional)
To use the hostname instate of the IP, you can install the avahi-daemon:
sudo apt install avahi-daemon
And you can config your hostname:
sudo raspi-config
In 2 Network Options > N1 Hostname, you can edit the hostname of your Raspberry Pi. After a reboot, you can use http://<hostname>.local/ to open the web interface.
Last updated
Was this helpful?
