There would be a couple of major obstacles to successfully use of WWI style railway guns in the 1850-1880’s. The first is metallurgy; the techniques needed to cast long steel weapons barrels had not been invented yet. Cannon were still brass & cast iron during the US Civil war (and attempts to make them more powerful were, at best, a bit spotty). A second problem is the propellant that could provide sufficient pressure to drive a shell a long distance had also not been developed (this is, in itself, a bit of the chicken & egg argument, as someone needed to create the one to spur creation of the other.)
Another issue is the mindset of the time. Bombarding civilians was not considered to be overly honorable (even during the early parts of WWI) and it an open question if such a weapon would have been used by most combatants of the era.
BTW: As an aside, it is very likely that Generals Harris, LeMay, and their fellows would have been tried as war criminals had the other side won WW II. It was (and frankly is) difficult to fit mass bombardment of civilian populations under the umbrella of the various Geneva Conventions. This not to say that the tactic was wrong to use, or that is wasn’t effective, just that if you use you had better be bloody sure that you win.