Created
July 4, 2017 07:38
-
-
Save wikrie/c1da1b321fa92483bbafb429b8d440ec to your computer and use it in GitHub Desktop.
create a VHOST with SSL Letsencrypt on RASPI
This file contains 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 | |
# Script for creating Vhosts with nginx conf and Letsencrypt Cert directly. | |
read -p "Gib die komplette URL der Domain ein: " domain | |
# mit www-data Berechtigung das HTML ROOT anlegen | |
sudo -u www-data mkdir /var/www/vhosts/$domain | |
# die standard Index files rein kopieren. | |
sudo cp /var/www/html/index.nginx-debian.html /var/www/vhosts/$domain/index.html | |
# ein nginx conf file erstellen | |
sudo cp /etc/nginx/templates/template.conf /etc/nginx/templates/tmp/$domain'.conf' | |
# in dem erstellten conf file die defuialt werte mit den domain werten überschreiben | |
sudo sed -i -e 's/tobechange/'$domain'/g' /etc/nginx/templates/tmp/$domain'.conf' | |
# die fertige conf in den echten Conf ordner schieben | |
sudo mv /etc/nginx/templates/tmp/* /etc/nginx/conf.d/ | |
# need restart nginx to get certrequest workign | |
sudo service nginx restart | |
# mittels certbot ei Cert für diese neue Domain holen | |
sudo certbot certonly --webroot -w /var/www/vhosts/$domain -d $domain | |
# jetzt noch die finale conf erstellen und verschieben | |
sudo cp /etc/nginx/templates/template-ssl.conf /etc/nginx/templates/tmp/$domain'.conf' | |
sudo sed -i -e 's/tobechange/'$domain'/g' /etc/nginx/templates/tmp/$domain'.conf' | |
sudo mv -f /etc/nginx/templates/tmp/* /etc/nginx/conf.d/ | |
#nginx neu starten | |
sudo service nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment