I always thought it was when a war is contained and fought between two sides within the same country. But I'm realizing that every civil war has outside influence, for example, the International Brigades and German/Italian intervention during the Spanish Civil War of the late 1930s. Many thanks, /r/AskHistorians!
This is a very good question! I suspect that other users will have their thoughts on this - my own pet civil war has been name checked, but I've heard that there are others - but I can offer my own perspective at least.
To begin with, Spain, despite seeing substantial foreign intervention, is still a straightforward example of a civil war. No useful definition of civil war can preclude outside influence or intervention, as no civil conflict ever takes place within a complete vacuum. In the case of the Spanish Civil War, the scale of external interest and intervention was exceptional (which in turn is a big part of the reason I study it), mostly due to the international context it took place in, but it's still a matter of scale rather than inherent difference. The outcome of the Spanish Civil War was, in my opinion, likely decided by foreign intervention, which is perhaps unusual but I don't think unique.
So how then do we positively define civil war? To start with, I think any answer has to start with politics, and political systems. Civil wars fundamentally take place within (rather than between) political communities, with two (or more) sides competing for political legitimacy within that community. This last point, I think, helps distinguish civil war from a rebellion, in that no one side in a civil war can lay uncontested claim to political legitimacy. In modern times, a political system tends to mean a nation state, but the same definition would I think broadly hold true across time periods and different political systems - my understanding is that this kind of definition was coined in Ancient Rome following civil conflicts between Sulla and Marius, but this is very far from my area of expertise and I'll gladly defer to a specialist on this.
There are still plenty of grey areas. How do we distinguish, for example, between a revolution and civil war? I don't think any neat categorisation is possible here, beyond perception: a revolution is potentially modernising and positive, while civil war is always regressive and damaging - though in turn revolutionaries might accept civil war as a necessary price to pay to achieve their goals. Certain groups in a society might actively call for revolution; no one hopes for civil war. Religious wars, particularly in the medieval and early modern period, are also challenging to fit within this definition - conflict between Catholics and Protestants, for instance, might take place within a political system, but can simultaneously reflect or form part of a wider international conflict. Even in relatively straightforward examples of civil wars, the terminology employed might be contested - in Spain, for example, both sides were keen to characterise the situation as a 'rebellion', thereby denying their opponents legitimacy. This is where the inevitably of foreign involvement in modern civil wars comes in - ultimately, legitimacy is in part the product of international recognition, so who other countries choose to recognise (or not) as the legitimate government or representatives of a political community carries significant weight.
If you want to read more about this, there's a major recent publication covering the intellectual history of civil war as a concept: David Armitage, Civil Wars: A History in Ideas (New York, 2017). I've drawn the gist of my answer (apart from the Spain-specific stuff) from this text, though have obviously not given anything more than the broadest summary.