Chapter 7: Delete & Replace Files
Now that your site files, &, if required, your database, have been backed up, it’s time to remove all files from the site. Navigate to the folder where your website is stored, select the files & folders within that folder, (the easiest way is likely to press control+a, i.e., hold down the control key while simultaneously pressing the a key), then press the delete key. You’ll be prompted to make sure you want to do that. Agree w/the prompt & wait till the operation has finished. Note: do not delete the folder in which your website files are stored.
If your site is simply an HTML & CSS-based site, then all you need to do is to upload known good copies of your files, & you’re finished. If, however, your site is CMS-based, there are several ways you can reinstall your site. The easiest is probably to use your hosting provider’s control panel. If it happens to have Softaculous as a software installer, I particularly like it because, from my experience, it always has the latest version of the scripts, unlike others I’ve seen where you have to update immediately after installation to get the latest version.
Please check out:
Installing a Website Using Softaculous
for how to do that. Be sure to consult the notes specific to your CMS.
To reinstall your website using the same folder & database as your current site, you can enter the directory name where your site was installed previously, if any, then click the ‘Advanced’ Options tab, where you can enter the name of the database you wish to use, which, in this case, is the database name of your previous site.
Installing via Softaculous is a good deal faster than most file transfer methods.
If you do not have a script installer available through your hosting provider, which I find difficult to imagine, as almost all do, then you can use FTP or your hosting provider’s file manager to install the site. This varies considerably with the content management system you’re installing, & is therefore beyond the scope of this article.
Once you’ve finished the installation, you have a fresh install of all your CMS’s core files. All that’s left now is either to upload your old configuration file to the server, or to modify the sample one your CMS provides with the appropriate database credentials. If you do decide to use the site’s previous configuration file, look through it to ensure the criminals haven’t put bad stuff there. Comparing it to a sample configuration file provided by your CMS should help you readily spot & delete any tainted lines. You’ll also need to re-upload any user-generated content such as pictures, documents, & multimedia files you had used on your site.
At this point, assuming you’ve entered the configuration information correctly, the site should be operable, & you should be able to log into it. If you receive an error connecting to the database, ensure that your database name, username, hostname, & password are correct. You can then install 3rd-party software such as modules/plugins & themes either through your dashboard or via a secure file transfer method.
Congratulations! Your site is now functional & hack-free.