I have from time to time researched this issue, but I could never find exactly some answer related to this kind of setup. This is because the phone-industry terminology is unknown to me, and whenever I would search for this, I would always find answers about VoIP/SIP or about PBX and Asterisk.
But I was never able to find something about setting-up your own telephone-gateway, without connecting to a SIP provider.
(Basically, I wanted to know how you can be SIP provider)
Fortunately today is my lucky day, as I found these links as a starting point:
Especially the last link is very useful, with an example of an actual FXO card (it's the first time I hear this term, it seems it's only known by VoIP professionals, and it's kept quite "hidden" from the consumers ears)
Now I still have to learn which software to use for this setup. (From the last link it looks like Asterisk has builtin support, but I have to check it.)