You'd need to get to Algeciras to take the Ferry. That either involves an overnight bus ride to Seville (or a split-up ride to Faro and from Faro to Seville) and a 2-hr bus ride to Algeciras.
Time-wise you'd probably be better off to just use miles to fly LIS-RAK/CMN, but you can also find many Spain-Morocco deals (on Ryanair and other carriers) and LIS-MAD is also quite cheap.
Back in May, I ended up doing LIS-SVQ (Beech 1900), bus to ferry, ferry to Tangier, night train to RAK, day train RAK-CMN and CMN-LIS on TP. Price-wise, flights through Spain are cheaper.