Skip to content

Instantly share code, notes, and snippets.

@garryspins
Created May 12, 2021 19:50
Show Gist options
  • Save garryspins/5fe9d809e5f427a15802534ca3994447 to your computer and use it in GitHub Desktop.
Save garryspins/5fe9d809e5f427a15802534ca3994447 to your computer and use it in GitHub Desktop.
Just a site generator for apache, idk
#!/bin/bash
alias a="sudo apt"
if [ $# -eq 0 ]; then
echo "Please give a domain";
fi
mkdir -p /var/www/$1/public_html
chown -R root:root /var/www/$1/public_html
chmod -R 755 /var/www/
echo "
<html>
<head>
<title>Test Page Lmao</title>
</head>
<body>
kiss me where it smells funny
</body>
<style>
html, body {
margin:0;
padding:0;
background-color:#313131;
height:100%;
color:#FFF;
}
</style>
</html>
" > /var/www/$1/public_html/index.html
echo "
<VirtualHost *:80>
ServerAdmin admin@$1
ServerName $1
ServerAlias www.$1
DocumentRoot /var/www/$1/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
" > /etc/apache2/sites-available/$1.conf > /dev/null 2>&1
a2ensite $1.conf > /dev/null 2>&1
a2dissite 000-default.conf > /dev/null 2>&1
apache2ctl configtest > /dev/null 2>&1
systemctl restart apache2 > /dev/null 2>&1
echo "Set your nameservers for $1 now moron"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment