technology,

How to Setup the Caddy Web Server as a Windows Service

Jai Jai Follow Mar 22, 2020 · 1 min read
How to Setup the Caddy Web Server as a Windows Service
Share this

# How to Setup the Caddy Web Server as a Windows Service

Automatically start Caddy web services whenever your machine boots.

Requirements

  1. Download Nssm
  2. Add Nssm folder to ENV path Example- path : D:\nssm-2.24\win64
  3. Download Caddy Server
  4. Add caddy folder to ENV path
  • Env = Environment Variables.
  • After download extract the files in ur Drive.

Lets make sure its working

  1. Open Cmd and type the command Nssm [Test if its working fine]

Caddy file

  1. Open Cmd and type the command Caddy [Test if its working fine]

enter image description here

Add Caddy Server in Nssm

  • Open Cmd and type Nssm install caddy, Nssm application will be opened
  • Example nssm_install

  • Now add Caddy.exe path to your nssm nssm_caddy

Explanation C:

  • Now Im passing Caddy arguments that is -conf [location of caddy conf file]
  • Example : -conf D:\Softwares\CaddyServer\anothercaddyfile.conf
  • Example : -conf C:\path\to\Caddyfile.conf
  • Example of my conf file

     localhost:8888 {
     root "D:/any folder to be served/"
     browse
     gzip
     }
    

    The lines following a site address start with a directive. Directives are keywords that Caddy recognizes. For example, gzip is an HTTP directive:

  • For more information about what to add in conf File check the Tutorial of Caddy Documentation

  • Now click on install service .. Caddy service will be successfully installed.

  • To check the caddy server CLick windows ->start - Services.msc

services.msc

Note : If the services are not running Click on Restart Or Resume in Services msc or Open Cmd run this command ->Nssm start caddy(service name you have created)

Check your localhost://port files are served

Hope this article helps, Please post the comment if you face any errors.

Join Newsletter
Get the latest news right in your inbox. We never spam!
Jai
Written by Jai Follow
Blogger, exploring new ideas and learning to code.