38

I'd like to start over with my webserver and I'd like to reinstall all the LAMP packages, how do I do that?

2
  • 3
    Just for yours and anyone else's information. After uninstalling LAMP with with this command: sudo apt-get remove lamp-server^ MANY things/software were removed. Things that you would think are unrelated... Now when I try to boot, it just hangs at the terminal after rebooting ...[Ok]
    – user71456
    Jun 18, 2012 at 13:42
  • Anyway I can check if its completely removed or not? Link or coomand or something? Sep 26, 2015 at 6:10

4 Answers 4

50

sudo apt-get purge mysql-server apache2 php5

That will remove the "big-boy" packages, which should take care of most cases.

You can find this information in the documentation, specifically this section on how to start over:

To remove the LAMP stack remove the following packages:

Note: This assumes you have no other programs that require any of these packages. You might wish to simulate this removal first, and only remove the packages that don't cause removal of something desired.

sudo apt-get remove apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-common php5-mysql

To also remove the debconf data, use the purge option when removing. To get rid of any configurations you may have made to apache, manually remove the /etc/apache2 directory once the packages have been removed.

Don't use tasksel to remove packages, bad things can happen, this is covered in this bug report.

The rest of the documentation covers how you would reinstall apache and all the stuff you'll need to get going again.

4
  • This worked for me: sudo apt-get purge apache2 php5-cli apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libnet-daemon-perl libplrpc-perl libpq5 mysql-client mysql-common mysql-server php5-common php5-mysql phpmyadmin && sudo apt-get autoremove Using: "PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli), Apache/2.2.22 (Ubuntu), mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (x86_64) using readline 6.2"
    – quantme
    May 30, 2013 at 23:32
  • Anyway I can check if its completely removed or not? Link or coomand or something? Sep 26, 2015 at 6:10
  • It's not working for me it says E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? Mar 1, 2016 at 19:22
  • You're assuming that php5 is the only version available Aug 1, 2017 at 8:02
9

Remove LAMP

sudo apt-get purge libapache2-mod-auth-mysql phpmyadmin
sudo apt-get purge mysql-server mysql-server-5.1 mysql-server-core-5.1
sudo apt-get purge apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5
sudo apt-get autoremove

Install LAMP

Run tasksel Select LAMP server.

To fully manage your lamp Server database, install phpmyadmin

sudo apt-get install phpmyadmin

4
  • 7
    please note: I ran "sudo apt-get remove lamp-server^" and it removed almost everything on my machine. On the next reboot, I couldn't even get to my desktop. Oct 23, 2012 at 14:09
  • Same here, ruined my ubuntu install with sudo apt-get remove lamp-server^
    – ppp
    Jan 5, 2013 at 11:21
  • Wow! ^ It is happening right now as I comment and I had no idea. just saw it removing python3-apparmour and realised something was wrong. Wish I had read this before. Aug 5, 2014 at 5:41
  • Anyway I can check if its completely removed or not? Link or coomand or something? Sep 26, 2015 at 6:10
2
sudo apt-get purge apache2 php5-cli apache2-mpm-prefork apache2-utils apache2.2-common \
     libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl \
     libnet-daemon-perl libplrpc-perl libpq5 mysql-client mysql-common mysql-server \
     php5-common php5-mysql phpmyadmin \
&& sudo apt-get autoremove
1

new version of LAMP Stack can be uninstalled by

$ sudo /opt/lampstack-[version]/uninstall

e.g

$ sudo /opt/lampstack-7.1.22-2/uninstall

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .