Skip to content

Instantly share code, notes, and snippets.

@geforester
Last active February 3, 2022 23:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geforester/34039ecb9e06095a28be4616c534d62d to your computer and use it in GitHub Desktop.
Save geforester/34039ecb9e06095a28be4616c534d62d to your computer and use it in GitHub Desktop.
Ubuntu 10.04 (nginx + php5-fpm): remove site including user & database
#!/bin/bash
ROOTPASS='password'
echo "Enter username to delete:"
read USERNAME
mysql -uroot --password=$ROOTPASS -e "DROP USER $USERNAME@localhost"
mysql -uroot --password=$ROOTPASS -e "DROP DATABASE $USERNAME"
rm -f /etc/nginx/sites-enabled/$USERNAME.conf
rm -f /etc/nginx/sites-available/$USERNAME.conf
rm -f /etc/php/7.4/fpm/pool.d/$USERNAME.conf
find /var/log/nginx/ -type f -name "$USERNAME-*" -exec rm '{}' \;
service nginx reload
service php7.4-fpm reload
userdel -rf $USERNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment