Installing Nezha Agent on Windows and Linux Systems

Windows Installation

Prerequisites

  • Operating System: Windows Server
  • Software Required: Nezha Agent and NSSM (download both)

Environment Setup

Extract the downloaded files to any directory. Press Win + R, type sysdm.cpl, and open System Properties → Advanced → Environment Variables → System Variables. Add the NSSM directory path to the end of the Path variable using semicolons (;) to separate entries.

Note: On Windows 10, ensure semicolons are used correctly between paths.

NSSM Configuration

Run Command Prompt as Adminsitrator:

nssm install nezha

In the UI dialog, configure the following parameters:

-startup parameters: -s {ServerIP}:{Port} -p {AgentKey} -d

Ensure no curly braces {} are included in the command. After setting up, click "Install Service" and run:

nssm start nezha

Common NSSM commands:

# Install service
nssm install <service-name>

# Remove service
nssm remove <service-name>

# Control service
nssm start <service-name>
nssm stop <service-name>
nssm restart <service-name>

# Check status
nssm status <service-name>

Linux Installation

Prerequisites

  • Operating System: Linux Server
  • Softawre Required: Nezha Agent for Linux

Setup Steps

Place the agent binary in /opt/nezha/agent/ and grant execute permissions:

chmod +x /opt/nezha/agent/nezha-agent

Test the agent:

/opt/nezha/agent/nezha-agent -s 61.155.136.7:5555 -p 47505450286642c26d

To keep the agent running after logout, use systemd:

Create a service file:

vi /etc/systemd/system/nezha-agent.service

Add the following content:

[Unit]
Description=Nezha Agent
After=syslog.target
Type=simple
User=root
Group=root
WorkingDirectory=/opt/nezha/agent/
ExecStart=/opt/nezha/agent/nezha-agent -s 61.155.136.7:5555 -p 302e5e5cb34d511a53
Restart=always

[Install]
WantedBy=multi-user.target

Enable and start the service:

systemctl enable nezha-agent.service
systemctl start nezha-agent.service

Customizing Default Theme CSS

The following CSS modifications adjust visual elements of the dashboard:

/* Responsive container */
@media only screen and (min-width: 1200px) {
  .ui.container {
    width: 77%;
  }
}

@media only screen and (max-width: 767px) {
  .ui.card>.content>.header:not(.ui), .ui.cards>.card>.content>.header:not(.ui) {
    margin-top: 0.4em;
  }
}

/* Icon styling */
i.icon {
  color: #000;
  width: 1em !important;
}

/* Menu customization */
.ui.large.menu {
  border: 0;
  border-radius: 0px;
  background-color: rgba(255, 255, 255, 55%);
}

.ui.menu .active.item {
  background-color: transparent;
}

.ui.dropdown .menu {
  border: 0;
  border-radius: 0px;
  background-color: rgba(255, 255, 255, 55%);
}

/* Login button */
.nezha-primary-btn {
  background-color: #21ba45 !important;
  color: #fff;
}

/* Background image */
body {
  background: fixed;
  z-index: -1;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-position: top;
  background-repeat: no-repeat;
  background-size: cover;
  background-image: url(https://picture.mefj.com.cn/%E5%B4%96%E4%B8%8A%E7%9A%84%E6%B3%A2%E5%A6%9E4k%E9%AB%98%E6%B8%85%E5%A3%81%E7%BA%B8.jpg);
  font-family: Arial,Helvetica,sans-serif;
}

/* Card styles */
#app .ui.fluid.accordion {
  background-color: #fbfbfb26;
  border-radius: 0.6rem;
}

.ui.four.cards>.card {
  border-radius: 0.6rem;
  background-color: #fafafaa3;
}

/* Icon colors */
.nezha-secondary-font {
  color: rgba(252, 166, 7, 0.952) !important;
}

/* Popup positioning */
.ui.right.center.popup {
  margin: -3px 0 0 0.914286em !important;
}

/* Progress bar styling */
.ui.progress {
  border-radius: 40rem;
}

.ui.progress .bar {
  min-width: 1.85em !important;
  border-radius: 15px;
  line-height: 1.65em;
}

.ui.fine.progress > .bar {
  background-color: #21ba45 !important;
}

.ui.progress > .bar {
  background-color: #000 !important;
}

/* Upload/download icons */
i.arrow.alternate.circle.down.outline.icon {
  color: green;
}

i.arrow.alternate.circle.up.outline.icon {
  color: #ff0000;
}

/* Table styling */
.ui.table {
  background: RGB(225,225,225,0.6) !important;
}

.ui.table thead th {
  background: transparent !important;
}

.service-status .good {
  background-color: #21ba45 !important;
}

.service-status .danger {
  background-color: red !important;
}

.service-status .warning {
  background-color: orange !important;
}

/* Footer */
.ui.inverted.segment, .ui.primary.inverted.segment {
  color: #000;
  font-weight: bold;
  background-color: #fafafaa3;
}

JavaScript snippet to modify footer text:

window.onload = function(){
  var avatar=document.querySelector(".item img");
  var footer=document.querySelector("div.is-size-7");
  footer.innerHTML="©2021 运维密码 & Powered by TLFang";
}

Project Repository: https://github.com/naiba/nezha

Tags: nezha Agent Windows Linux installation

Posted on Sun, 21 Jun 2026 17:56:14 +0000 by BigX