# How to Setup the Caddy Web Server as a Windows Service
Automatically start Caddy web services whenever your machine boots.
Requirements
- Download Nssm
- Add Nssm folder to ENV path Example- path : D:\nssm-2.24\win64
- Download Caddy Server
- Add caddy folder to ENV path
- Env = Environment Variables.
- After download extract the files in ur Drive.
Lets make sure its working
- Open Cmd and type the command Nssm [Test if its working fine]
- Open Cmd and type the command Caddy [Test if its working fine]
Add Caddy Server in Nssm
- Open Cmd and type Nssm install caddy, Nssm application will be opened
- Example
- Now add Caddy.exe path to your nssm
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
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.
Views: 111