My problem is that I want me and my friend to be able to play on a survival world together, but we live at different locations. I know I can visit a hosting website but I don't want to pay money because it's just me and my friend. Would there be any way for us to play together without paying any money? My problem is different from that one because we don't want to connect through LAN he is at a different location than me.
How to host a Minecraft Server
The only way to be able to play with your friend if you live in different location is to setup your own minecraft server. Before I continue, I'd like to warn you that creating a server does take a bit of computer and networking skills. I would put up a whole guide to doing it, but as I had a lot of problem with it myself, I'll just refer you to the Minecraft Wiki Page that will help.
Minecraft Wiki: How to setup a server
If you're still having trouble, just do some quick searches on Google or Youtube (I'd recommend Youtube as there are more results) to find any problems you have with setting up a server.