Reinstalling a LAMP stack on Ubuntu

This is to reinstall a LAMP stack on Ubuntu Jaunty, but it should work for pretty much any version.

Shut down Apache:
sudo /etc/init.d/apache2 stop
Shut down MySQL:
sudo /etc/init.d/mysql stop
Remove the entire LAMP stack:
sudo apt-get purge apache2 php5-mysql libapache2-mod-php5 mysql-server php5 phpmyadmin
  • Note the use of purge instead of remove -- this gets rid of configuration files as well.
  • You will need to download everything from the archives during the reinstall.
  • Stuff in /var/www will not be removed.
Now perform a new installation:
sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server php5 phpmyadmin