I am not sure what the answer is about getting a visa via the ship and the best way to find out is by asking your agent or the cruise line concerned. What I do know is that to tour independently in Egypt can be a very dodgy business, depending on where you want to go, and most tours to say The Pyramids or Luxor go off in convoy with guards accompanying the convoy. In this area please be sure about the consequences of your actions and what ever you do don't miss the sailing time....regards Nei.
In a company where I worked years ago I use to travel to Egypt many times, and I personally don't recommend independent excursions as you are dealing with a very different culture (not better or worse, but only very different); so I must agree with Neil Down's advice to yo.
If you are thinking of going from a Med port to Cairo forget it. You can only really do it with the ships trip and remember that if you go independantly then be it on your own head if you are late and I suspect that the next port is in a far distant country.If you just wish to go ashore and look round the port then you can get a visa on arrival for £15. I do not recommend this and certainly do not recommend trying to do your own trip for a longish distance. They all have to wait for the convoy anyway so you cannot do your own thin.