The Man in Seat 61 has a page that discusses how to get from London to Morocco by train and ferry. Eurostar from London to Paris, TGV from Paris to Barcelona, overnight in Barcelona, AVE and Spanish regional rail for Barcelona to Algeciras, free bus to the ferry terminal, ferry to Tangier Med Port, train/bus/taxi to the center of Tangier (or the FRS ferry directly to Tangier). From Tangier, there are further rail connections to other points in Morocco. If you're not starting in London, substitute the appropriate rail connections to get to Paris or Barcelona and pick up the route from there. There are also other ferry options, such as periodic cruise ferries from Barcelona and France, which the linked page describes.
"Feasible" is a relative term though. It's absolutely possible, but not particularly efficient. A flight takes a couple hours, plus time at the airport on each end, while the train/ferry journey requires about two-three days depending on your starting and ending points. This is due to the combination of the journey times and schedules for connections. Paris to Barcelona alone is over six hours, and that's only one segment of the trip. It still sounds like a fun trip though, if you can spare the time.
Why does it take so long? Paris to Algeciras alone is more than 1,500km as the crow flies—rome2rio thinks it would take 18 hours to drive without stops. High speed rail saves you some time over a car, but you give up much of that time in the connections—some of these trains only run a few times a day.