0

I need to submit a website and get trouble from server. Not sure how bad.I am setting up a simple website on a server I am ssh'd to. I tried to rsync a couple files in to my /var/www/html folder, accidentally synced my whole desktop, and then accidentally cleared the whole /HTML folder. (Bad, I know). I am trying to figure out how to set up the server again, if I can. Here's some details-

When I try to access the server I get a 403 forbidden. When I tried to install Apache2 I got "apache2 is already the newest version (2.4.18-2ubuntu3.10)."

There is seemingly no /etc/httpd folder that I am seeing in some tutorials, there is an etc./apache2 folder.

Not sure where to go from here. Any advice would be greatly appreciated!

6
  • The server is installed and the 403 is a clear indication that it is working. Forbidden means you are not allowed access to the page you requested. Putting back the files you removed seems like the only sane fix; we can't know what you had there, but if you didn't have anything useful there, you can purge the package and install it again to have the contents recreated.
    – tripleee
    Jul 19, 2019 at 10:03
  • ..files are gone for good i fear, but i dont think i had anything useful there, ill look into purging the package then. Do you mean I should purge the apache package? as in 'apt-get purge apache2' ? then just reinstall it?
    – derric-d
    Jul 19, 2019 at 10:13
  • Yes, exactly. This should repopulate /var/www/html if it is missing, I believe.
    – tripleee
    Jul 19, 2019 at 10:13
  • okay, then ill try purgeand 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?
    – derric-d
    Jul 19, 2019 at 10:22
  • I don't understand "from there I can start my website". If you mean "then I can add or replace files in /var/www/html with the content I actually want to serve" then yes, exactly.
    – tripleee
    Jul 19, 2019 at 10:41

1 Answer 1

0

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.

You must log in to answer this question.

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