Debugging stand-alone, and server-side scripts is essentially the same.
You don't necessarily have a document.write() method but you will certainly have a means of printing text. In the case of a server side script, that may be the way you construct the response so you can put debugging information in the response, so that it can be viewed by from the web browser.
You might not want to do that if you are debugging some security related services though. In that case, your web server probably has a logging capability and you might be able to write to the error log.