How to Reinstall apache2 properly in linux

If you have issues with apache2 and you want to reinstall it but you are getting errors,then here it isthe solution for you.


For example, me i had an issue with apache, when i tried to start it i got this error message  :


root@pirat9-desktop:/etc/apache2# /etc/init.d/apache2   start
.: 45: Can't open /etc/apache2/envvars

Now i want to reinstall apache, but first i need to remove it completely  (If you currently have it removed improperly, reinstall it by “sudo apt-get install apache2” before to use the command bellow). To do that i will use this command :

 sudo apt-get remove --purge apache2 apache2-utils

This command will completely remove all apache2 configuration files and directories.
– Reinstall again apache using the normal command

sudo apt-get install apache2

Now your config files and directories in /etc/apache2 all be back and at their defaults as well as the “apache2-utils previously removed.

root@pirat9-desktop:/etc/apache2# /etc/init.d/apache2   start
 * Starting web server apache2                                 
using for ServerName
httpd (pid 7235) already running   [ OK ]

For any question please don`t hesitate to ask us.

{loadposition user9}

Related Articles By Tags:

{loadposition user1}

  • Dema

    ok! Спасибо за подсказку, сутки не мог переустановить. :D

  • Yusuef

    Thank you. :wink: :wink: :wink: :wink:

  • Zinovsky

    You are welcome

  • sinatria

    Thank’s for information, so helping :)

  • ck

    thanks a lot.
    I install phpmyadmin and then I can’t reinstall apache2. Now everything is alright…

  • MortonAUDREY31

    Don’t you know that this is high time to get the loan, which would make your dreams come true.

  • Maxime

    My fu**ing god ! Thanks you so much ! :) Good job ! Thanks man !

  • Lizardzk

    thanks for your tutorial,,
    this very help me,,,,,

  • faboulaws

    thanks a lot.tried to set up SSL and my apache stopped working article helped me reset my apache on Ubuntu 12

  • Bryan Headrick

    I did this, and I’m still getting the same error.

  • Gingelly Oil


  • zman360

    Thanks – helped update my localhost server. However, I notice that I have to use sudo with almost every command in the terminal window now, which is changed from previous. Is my newer apache2 version more secure? Any way to fix this so I can execute the same java programs as before? Thanks.

  • Pingback: Setting up the Apache Server | Garden GNOMEing()