Skip to content

Instantly share code, notes, and snippets.

@Ravaelles
Last active October 18, 2019 15:02
Show Gist options
  • Save Ravaelles/dbddd5f136dee40fd7ab9fef3fd1e2ad to your computer and use it in GitHub Desktop.
Save Ravaelles/dbddd5f136dee40fd7ab9fef3fd1e2ad to your computer and use it in GitHub Desktop.
Script used to create new nginx site config files based on the file name and project path
# Ensure to get this file: https://tinyurl.com/genericlocal
# And that it's placed in: /etc/nginx/sites-enabled/generic.local
# Also make sure to have the certificate files! See generic.local at the end.
#
# Example usage: ./newdomain.sh cool /projects/MyProject
#
# After that you should be able to visit https://cool.local
cp /etc/nginx/sites-enabled/generic.local /etc/nginx/sites-enabled/$1.local
sed -i "s/PROJECT/$1/g" /etc/nginx/sites-enabled/$1.local
sed -i "s/DIRPATH/$2/g" /etc/nginx/sites-enabled/$1.local
sudo service nginx restart
printf "\nCreated nginx config file:\n/etc/nginx/sites-enabled/$1.local\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment