Long distance relationships are very difficult to maintain, even under the best of circumstances. That said, you need few ingredients to keep it going.
You have to have some kind of endgame. Long distance can't just go on and on with no end in sight. You have to have a plan to be together after some amount of time. And it has to be a realistic plan. One of you have to move to be close (live with) the other.
You need to have plenty of money for travels, just in case of emergency. Even if it's just a few hours driving distance between you, that will mean the cost of gas, train or bus fare. If it further away, you will need money for plane fare.
3)You have both have compatible time off to be able to visit each other. Maybe your significant other has weekends off, but you usually have to work weekends. So, how are you going to make it work? Will you both get vacation time for holidays? You have to evaluate your plans and see how likely it is that there will be time to spend at least a weekend together every so often. And along page as to how often you need to see each other to keep the relationship going.
You need to have some level of trust in each other. Do you have an agreement that when you're apart, you're free to date others? Or do you both expect faithfulness and monogamy? You need to be on the same page about this too. Of course, if you both agree, that it's OK to date others while you are apart, there's the risk that either of you might meet someone else you like better. That's a very big risk of a long distance relationship. Even if you plan to stay faithful to each other, things happen. Plus, there's the loneliness factor. It can be really tempting to seek comfort with someone elsewhere, just because it's been so long since you've seen your significant other. Or because you were planning a visit with your S. O. but then something came up and the plans had to be canceled.
You need a lot of patience, especially if you it's going to take a lot of time before you can be together. And you're going to have to patience to endure all the time, efforts and inconveniences of traveling back and forth in the meantime.
If you don't know each other very well, it is not a good idea to start up a long distance connection. It takes time and patience to get to know someone. And by that I mean, time spent with each other in person.
Do not attempt to do a long distance relationship with someone you've met online or do not know in person. Look for someone who lives in your area that you can see regularly to explore whether you are compatible, otherwise you may waste a lot of time and emotional entanglement in communicating with someone you get your hopes up about and they out not to be what you expected.
Relationships are built at a time, shared experiences upon shared experiences. There are numerous little things that go into getting to know each other and determining that you have similar values, goals, beliefs etc. You need regular in-person contact to develop your relationship. And even if you have had lots of time to get to know each other in person, then one of you have to go away to go to school or take up a job somewhere far away. It can be very difficult to hold onto your relationship from a long distance even if nobody else comes into the picture, you grow apart with your separate lives putting you through separate changes.
I guess your best chance for maintaining a long distance relationship is if you know each other really well before hand and the long distance between you will only be for a relatively short time