Skip to content

Instantly share code, notes, and snippets.

@binamonk
Last active March 25, 2021 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binamonk/f3639c64073fda42068c31c645f432c4 to your computer and use it in GitHub Desktop.
Save binamonk/f3639c64073fda42068c31c645f432c4 to your computer and use it in GitHub Desktop.
Bash script to mount an apache2 server with database.
#!/bin/sh
apt update
apt install -y ufw
apt install -y apache2
apt install -y php libapache2-mod-php
apt install -y php-mysql php-xml
apt install -y mariadb-server
systemctl restart apache2
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow http
ufw allow https
ufw enable
wget https://wordpress.org/latest.tar.gz -P /var/www
tar -xzf /var/www/latest.tar.gz
rm /var/www/html/*
mv /var/www/wordpress/* /var/www/html
rmdir /var/www/wordpress
chown -R www-data /var/www/html/
echo "deb http://ftp.debian.org/debian buster-backports main" >> /etc/apt/sources.list
apt update
apt install -y python-certbot-apache -t buster-backports
# modify /etc/apache2/sites-available/000-default.conf and add ServerName
certbot --apache -d dev-01.yourdomain.com
# certbot --apache -d dev-01.yourdomain.com
# mysql_secure_installation
CREATE DATABASE domain_db;
GRANT ALL PRIVILEGES ON wordpress.* TO "domain_user"@"localhost" IDENTIFIED BY "domainPWD!";
FLUSH PRIVILEGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment