Matthieu Mollard Matthieu Mollard - 5 months ago 27
Apache Configuration Question

How to reset a Linux VPS to 0 in one command?

I'm the owner of a VPS server and my goal is that the server reinstalls itself from zero, I explain:

  • Delete all user (except root) and all file who are not Linux file (so delete all the non native file)

  • Deinstall Apache and MySQL

  • Reinstall Apache and MySQL and import table from external .sql file

  • wget .tar of website and untar it

Except for the last step, I'm a little bit lost.


Delete all user before you do that perform a backup of the user

sudo tar jcvf /user-backups/linux-user.tar.bz2 /home/linux-user

Issue delete user command along with deleteting user files

sudo deluser --remove-home linux-user
sudo deluser --remove-all-files linux-user 

Remove mysql and apache completely

 sudo apt-get --purge remove mysql-client mysql-server mysql-common
 sudo apt-get autoremove

 sudo rm -rf /etc/mysql/
 sudo apt-get purge apache2*

Install apache

sudo apt-get install apache2

Install mysql

sudo apt-get install mysql-server libapache2-mod-auth-mysql
sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation

Enter current password for root (enter for none): 

OK, successfully used password, moving on...

Once mysql is installed, issue

mysql -u root -p

Enter password to login.

create database mysql_database;

Go to the command prompt and issue

mysql -u root -p mysql_table < path_to_mysql_sql_file.sql

wget .tar of website and untar it when you're at /var/www/html issue

  sudo wget

Then issue this following command

  sudo tar xvf the-tar-file.tar

The command above will extract the files and folders from the tar archive.