Because you are asking specifically about reinstalling Apache to reach your goal, I'll explain how to do that in some more detail. Another, more general and at least in some scenarios simpler way to recover system files to their original state is to obtain them from another system with a similar configuration. If you use Docker, a pristine Docker image of your OS version is nice to have around for a number of reasons.
Now, as you already discovered, simply telling Apt that you want apache2
to be installed when it already is will not do anything. And simply removing apache2
will probably not work, either - merely uninstalling a .deb
package will remove binaries and libraries etc, but leave configuration files and configuration data on the system. You want to purge
the package to completely remove it, so you can do a complete, clean reinstall.
Of course, if you have some configuration changes that you would like to keep, you'll need to make a copy of those configuration files elsewhere before you purge, and restore your preferred configuration from this backup when you are done reinstalling. (The proper way to do this on Debian-based platforms is with debconf
; see also https://superuser.com/a/297156/97118)
Needless to say, proper backups would have saved you from these chores entirely. Another change you could make is to separate your development environment from your live system - I'll mention Docker again as a simple way to run potentially unstable things in a separate isolated environment which you can easily ditch and recreate at any time.
purge
the package and install it again to have the contents recreated./var/www/html
if it is missing, I believe.purge
and hope it works.. so i can expect to get the apache welcome page, not a 403 after this? and from there i can start my website again?/var/www/html
with the content I actually want to serve" then yes, exactly.