How can I set up my own FHIR server from scratch?
You need to choose FHIR Server you want to install and read there installation guide. You can check http://hapifhir.io/download.html for HAPI FHIR Server
There is also a large selection of examples at the git hub
For example, this submodule is a spring boot wired to JPA/Hibernate