I've always found the Asterisk documentation to be quite good.
There used to be lots of useful information at
https://voip-info.org, but it's been a few years since I last visited the site, so I can't vouch for the content that's currently there.
Anyway, the procedure would look something like this:
- Acquire a server
- If a physical landline or mobile connection is required: Buy an Asterix-supported FXO card capable of interfacing with your network of choice
- If needed: Open a VoIP account somewhere
- Install the OS
- Install Asterisk
- Configure DAHDI to talk to your FXO card (if present)
- Configure the external SIP account (if you have one)
- Configure accounts for local SIP devices/applications (phones/softphones)
- Create a dialplan
- Profit?