1# Fossil as a Windows Service 2 3If you need Fossil to start automatically on Windows, it is suggested to install 4Fossil as a Windows Service. 5 6## Assumptions 7 81. You have Administrative access to a Windows 2012r2 or above server. 92. You have PowerShell 5.1 or above installed. 10 11## Place Fossil on Server 12 13However you obtained your copy of Fossil, it is recommended that you follow 14Windows conventions and place it within `\Program Files\FossilSCM`. Since 15Fossil 2.10 is a 64bit binary, this is the proper location for the executable. 16This way Fossil is at an expected location and you will have minimal issues with 17Windows interfering in your ability to run Fossil as a service. You will need 18Administrative rights to place fossil at the recommended location. If you will 19only be running Fossil as a service, you do not need to add this location to the 20path, though you may do so if you wish. 21 22## Installing Fossil as a Service 23 24Luckily the hard work to use Fossil as a Windows Service has been done by the 25Fossil team. We simply have to install it with the proper command line options. 26Fossil on Windows has a command `fossil winsrv` to allow installing Fossil as a 27service on Windows. This command is only documented on the windows executable 28of Fossil. You must also run the command as administrator for it to be 29successful. 30 31### Fossil winsrv Example 32 33The simplest form of the command is: 34 35``` 36fossil winsrv create --repository D:/Path/to/Repo.fossil 37``` 38 39This will create a windows service named 'Fossil-DSCM' running under the local 40system account and accessible on port 8080 by default. `fossil winsrv` can also 41start, stop, and delete the service. For all available options, please execute 42`fossil help winsrv` on a windows install of Fossil. 43 44If you wish to server a directory of repositories, the `fossil winsrv` command 45requires a slightly different set of options vs. `fossil server`: 46 47``` 48fossil winsrv create --repository D:/Path/to/Repos --repolist 49``` 50 51 52### <a id='PowerShell'></a>Advanced service installation using PowerShell 53 54As great as `fossil winsrv` is, it does not have one to one reflection of all of 55the `fossil server` [options](/help?cmd=server). When you need to use some of 56the more advanced options, such as `--https`, `--skin`, or `--extroot`, you will 57need to use PowerShell to configure and install the Windows service. 58 59PowerShell provides the [New-Service](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-service?view=powershell-5.1) 60command, which we can use to install and configure Fossil as a service. The 61below should all be entered as a single line in an Administrative PowerShell 62console. 63 64```PowerShell 65New-Service -Name fossil -DisplayName fossil -BinaryPathName '"C:\Program Files\FossilSCM\fossil.exe" server --port 8080 --repolist "D:/Path/to/Repos"' -StartupType Automatic 66``` 67 68Please note the use of forward slashes in the repolist path passed to Fossil. 69Windows will accept either back slashes or forward slashes in path names, but 70Fossil has a preference for forward slashes. The use of `--repolist` will make 71this a multiple repository server. If you want to serve only a single 72repository, then leave off the `--repolist` parameter and provide the full path 73to the proper repository file. Other options are listed in the 74[fossil server](/help?cmd=server) documentation. 75 76The service will be installed by default to use the Local Service account. 77Since Fossil only needs access to local files, this is fine and causes no 78issues. The service will not be running once installed. You will need to start 79it to proceed (the `-StartupType Automatic` parameter to `New-Service` will 80result in the service auto-starting on boot). This can be done by entering 81 82```PowerShell 83Start-Service -Name fossil 84``` 85 86in the PowerShell console. 87 88Congratulations, you now have a base http accessible Fossil server running on 89Windows. 90 91### Removing the Windows Service 92 93If you want to remove the Fossil service, execute the following from an 94Administrative PowerShell or Command Prompt console: 95 96``` 97sc.exe delete fossil 98``` 99 100If you have Powershell version 6.0 or later, you can use: 101 102```PowerShell 103Remove-Service -Name fossil 104``` 105 106with the same effect. 107 108*[Return to the top-level Fossil server article.](../)* 109