Created
March 24, 2021 00:45
-
-
Save hierocles/ae3570aaebd3ee860b44c85e69000d1c to your computer and use it in GitHub Desktop.
ARM-based macOS implementation of Kevin Dees's bash script for nginx server creations - https://kevdees.com/macos-11-big-sur-nginx-setup-multiple-php-versions/
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
alias nginxreload="sudo nginx -s reload" | |
alias nginxrestart="sudo nginx -s stop && sudo nginx" | |
alias nginxservers="cd /opt/homebrew/etc/nginx/servers" | |
function nginxcreate() { | |
wget https://gist.githubusercontent.com/hierocles/395f4a1debecdf1f60f7bd5d8a989832/raw/43825d0c4c162f38845c1a835808e39d5db737ce/nginx-server-template.conf -O /opt/homebrew/etc/nginx/servers/$1.conf | |
sed -i '' "s:{{host}}:$1:" /opt/homebrew/etc/nginx/servers/$1.conf | |
if [ "$2" ]; then | |
sed -i '' "s:{{root}}:$2:" /opt/homebrew/etc/nginx/servers/$1.conf | |
else | |
sed -i '' "s:{{root}}:$HOME/Projects/$1:" /opt/homebrew/etc/nginx/servers/$1.conf | |
fi | |
nginxaddssl $1 | |
nginxrestart | |
code /opt/homebrew/etc/nginx/servers/$1.conf | |
} | |
function nginxaddssl() { | |
openssl req \ | |
-x509 -sha256 -nodes -newkey rsa:2048 -days 3650 \ | |
-subj "/CN=$1" \ | |
-reqexts SAN \ | |
-extensions SAN \ | |
-config <(cat /System/Library/OpenSSL/openssl.cnf; printf "[SAN]\nsubjectAltName=DNS:$1") \ | |
-keyout /opt/homebrew/etc/nginx/ssl/$1.key \ | |
-out /opt/homebrew/etc/nginx/ssl/$1.crt | |
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /opt/homebrew/etc/nginx/ssl/$1.crt | |
} | |
function nginxedit() { | |
code /opt/homebrew/etc/nginx/servers/$1 | |
} | |
function nginxlist() { | |
ll /opt/homebrew/etc/nginx/servers/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment