Created
November 19, 2017 15:08
-
-
Save frank-dspeed/c6d90c112bf537f9b002176b8d385f76 to your computer and use it in GitHub Desktop.
Bash Script to Create Domain debian ubuntu apache letsencrypt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Settings | |
# Path to the letsencrypt-auto tool | |
LE_TOOL=/opt/letsencrypt/letsencrypt-auto | |
#LE_TOOL=/opt/letsencrypt/letsencrypt | |
# Directory where the acme client puts the generated certs | |
LE_OUTPUT=/etc/letsencrypt/live | |
# Concat the requested domains | |
DOMAINS="" | |
for DOM in "$@" | |
do | |
DOMAINS+=" -d $DOM" | |
cp /etc/apache2/sites-available/targetvisionmedia.com.conf /etc/apache2/sites-available/$DOM.conf \ | |
&& mkdir -p /var/www/$DOM \ | |
&& sed -i "s/targetvisionmedia.com/$DOM/g" /etc/apache2/sites-available/$DOM.conf \ | |
&& chown -hR www-data:www-data /var/www \ | |
&& a2ensite $DOM | |
systemctl reload apache2 | |
#CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; | |
#CREATE DATABASE $DB; | |
#GRANT ALL PRIVILEGES ON $DB.* TO '$DB_USER'@'%' WITH GRANT OPTION; | |
#FLUSH PRIVILEGES; | |
$LE_TOOL certonly --webroot --webroot-path /var/www/$DOM --renew-by-default --email [email protected] --text --agree-tos -d $DOM | |
cp /etc/apache2/sites-available/targetvisionmedia.com-le-ssl.conf /etc/apache2/sites-available/${DOM}-le-ssl.conf | |
sed -i "s/targetvisionmedia.com/$DOM/g" /etc/apache2/sites-available/${DOM}-le-ssl.conf | |
a2ensite $DOM-le-ssl.conf | |
done | |
# letsencrypt certonly --webroot --webroot-path /var/www/$DOMAIN --renew-by-default --email [email protected] --text --agree-tos -d $DOMAIN -d www.$DOMAIN | |
# letsencrypt certonly --webroot --webroot-path /var/www/zorgverzekeringguru.nl --renew-by-default --email [email protected] --text --agree-tos -d zorgverzekeringguru.nl | |
# sudo chown -hR http:http PATH_TO_YOUR_WORDPRESS_FOLDER | |
# Create or renew certificate for the domain(s) supplied for this tool | |
#$LE_TOOL --agree-tos --renew-by-default --standalone --standalone-supported-challenges http-01 --http-01-port 9999 certonly $DOMAINS | |
# Cat the certificate chain and the private key together for haproxy | |
# cat $LE_OUTPUT/$1/{fullchain.pem,privkey.pem} > /etc/haproxy/ssl/${1}.pem | |
# Reload the haproxy daemon to activate the cert | |
systemctl reload apache2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment