Server.json
Everything needs some sort of configuration to allow a tool to work in the way that those responsible for it need it to work. For CFML engines, this historically has meant either using the web based Administrator to enter values into the server or directly editing large XML files which was cumbersome and potentially error-prone.
For CommandBox servers, that configuration can work by editing the server.json file. The JSON approach offers a solution which is more easily read, can be scripted rather than rely on a web based configuration solution and more easily debugged in case of problems.
We can either edit the server.json directly or from the CommandBox Interface. To start with, we're going to use CommandBox.
In CommandBox, make sure you are running it as the administrator. This does not need to always be the case but we have one feature in this set of instructions where it is essential.
Type
install commandbox-hostupdaterwhich will install that package from Forgebox. We'll talk more about package management in a bit.In CommandBox, navigate to the folder where you started the previous example.
We're going to change the URL by which we access that site by typing
server set web.host=justenough.local. Typeserver restartto restart the server and, when it is done restarting, typeserver open. The site is now being served on the just enough.local BUT is still being server over the alternative port.Type server set
web.http.port=80. Typeserver restartand thenserver open. The site is now being served over port 80. Thehostupdaterpackage adds the domain to your hosts file and configures your machine to server over port 80. This is why it was important to run CommandBox as the administrator for this activity. You can keep it that way or go back to running it under reduced privileges. Note: When starting the server for the first time with a new host, you might see a java.net.UnknownHostException. Simply restart the server again.To see the entire server.json from CommandBox type
server show. You can also edit the file directly in your IDE.
Last updated