sudo apt-get remove lamp-server^ --simulate
If that looks like what you want, remove the
--simulate flag and actually do the uninstall.
A variation of that, targeting relevant packages manually, would be along the lines of :
sudo apt-get --simulate remove mysql-server apache2 php5 libapache2-mod-php5 openssh-server openssl
If there are other packages that depend on things like
mysql that you want to keep, that might be a better way to go. Again, remove
--simulate to actually run the command. (With
-s is equivalent to
--simulate, and you would probably use it instead in day-to-day work.)
aptitude problem in particular, you might try
sudo apt-get autoclean and
sudo apt-get clean to see if that clears the error.