├── Makefile ├── README.md ├── bash_completion.d └── nginx_ensite ├── bin ├── nginx_dissite └── nginx_ensite ├── doc └── man │ └── nginx_ensite.8.ronn ├── nginx_ensite.sig └── share └── man └── man8 ├── index.txt ├── nginx_dissite.8 └── nginx_ensite.8 /Makefile: -------------------------------------------------------------------------------- 1 | SHELL=/usr/bin/env bash 2 | NAME=nginx_ensite 3 | VERSION=1.0.0 4 | AUTHOR=perusio 5 | URL=https://github.com/$(AUTHOR)/$(NAME) 6 | UPDATE_URL=https://raw.githubusercontent.com/$(AUTHOR)/$(NAME)/master 7 | UPDATE_FILES={{versions,stable}.txt,checksums.{md5,sha1,sha256,sha512}} 8 | 9 | DIRS=bin share 10 | INSTALL_DIRS=`find $(DIRS) -type d` 11 | INSTALL_FILES=`find $(DIRS) -type f` 12 | DOC_FILES=*.ronn 13 | 14 | PKG_DIR=pkg 15 | PKG_NAME=$(NAME)-$(VERSION) 16 | PKG=$(PKG_DIR)/$(PKG_NAME).tar.gz 17 | SIG=$(PKG_DIR)/$(PKG_NAME).asc 18 | 19 | PREFIX?=/usr/local 20 | DOC_DIR=$(PREFIX)/share/doc/$(PKG_NAME) 21 | COMPLETION_DIR=/etc/bash_completion.d 22 | CURR_DIR=`pwd` 23 | 24 | pkg: 25 | mkdir $(PKG_DIR) 26 | 27 | share/man/man8/nginx_ensite.8: doc/man/nginx_ensite.8.ronn 28 | ronn --pipe doc/man/nginx_ensite.8.ronn > share/man/man8/nginx_ensite.8 29 | 30 | man: doc/man/nginx_ensite.8.ronn share/man/man8/nginx_ensite.8 31 | git add doc/man/nginx_ensite.8.ronn share/man/man8/nginx_ensite.8 share/man/man8/nginx_dissite.8 32 | git commit 33 | 34 | download: pkg 35 | wget -O $(PKG) $(URL)/archive/v$(VERSION).tar.gz 36 | 37 | build: pkg 38 | git archive --output=$(PKG) --prefix=$(PKG_NAME)/ HEAD 39 | 40 | sign: $(PKG) 41 | gpg --sign --detach-sign --armor $(PKG) 42 | git add $(PKG).sig 43 | git commit $(PKG).sig -m "Added PGP signature for v$(VERSION)" 44 | git push origin master 45 | 46 | clean: 47 | rm -f $(PKG) $(SIG) 48 | 49 | all: $(PKG) $(SIG) 50 | 51 | tag: 52 | git push 53 | git tag -s -m "Releasing $(VERSION)" v$(VERSION) 54 | git push --tags 55 | 56 | release: tag download sign 57 | 58 | install: 59 | for dir in $(INSTALL_DIRS); do mkdir -p $(DESTDIR)$(PREFIX)/$$dir; done 60 | for file in $(INSTALL_FILES); do cp $$file $(DESTDIR)$(PREFIX)/$$file; done 61 | (cd $(DESTDIR)$(PREFIX)/bin && test -L nginx_dissite || ln -s nginx_ensite nginx_dissite) 62 | mkdir -p $(DESTDIR)$(DOC_DIR) 63 | cp -r doc/man/$(DOC_FILES) $(DESTDIR)$(DOC_DIR)/ 64 | mkdir -p $(COMPLETION_DIR) 65 | cp bash_completion.d/* $(COMPLETION_DIR)/ 66 | 67 | uninstall: 68 | for file in $(INSTALL_FILES); do rm -f $(DESTDIR)$(PREFIX)/$$file; done 69 | rm -rf $(DESTDIR)$(DOC_DIR) 70 | rm $(COMPLETION_DIR)/$(NAME) 71 | 72 | .PHONY: build man update download sign verify clean check test tag release rpm install uninstall all 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nginx_ensite and nginx_dissite for quick virtual host enabling and disabling 2 | 3 | ## Description 4 | 5 | This is a shell (Bash) script that replicates for 6 | [nginx](http://wiki.nginx.org) the [Debian](http://debian.org) 7 | `a2ensite` and `a2dissite` for enabling and disabling sites as virtual 8 | hosts in Apache 2.2/2.4. 9 | 10 | The original `a2ensite` and `a2dissite` is written in 11 | Perl. `a2dissite` is a symbolic link to `a2ensite`. Here I followed 12 | the same approach, i.e., `nginx_dissite` is a symbolic link to 13 | `nginx_ensite`. 14 | 15 | The script allows for arbitrary paths for the nginx configuration 16 | directories. This is particularly useful not only to those on Mac, but 17 | also in a microservice approach where each service has it's own vhost 18 | configuration, for example. 19 | 20 | Th deafult startup program is `service`. Feel free to pass another 21 | program. For example using nginx to send a `SIGHUP` to reload the 22 | configuration you just pass the option `-s nginx` to the script. 23 | 24 | ## Installation 25 | 26 | ### Automatic 27 | 28 | ``` 29 | git clone https://github.com/perusio/nginx_ensite.git 30 | cd nginx_ensite 31 | sudo make install 32 | ``` 33 | 34 | ### Manual 35 | 36 | Just drop the script and the symbolic link in `/usr/sbin` or other 37 | location appropriate for your system. Meaning: `cp nginx_* /usr/sbin`. 38 | That's it you're done. 39 | 40 | Note that the script assumes a specific file system topology for your 41 | `nginx` configuration. Here's the rundown: 42 | 43 | 1. All virtual hosts configuration files are by default under 44 | `/etc/nginx/sites-available`. For example the virtual host `foobar` 45 | is configured through a file in `/etc/nginx/sites-available`. 46 | 47 | 2. After running the script with `foobar` as argument: `nginx_ensite 48 | foobar`. A symbolic link `/etc/nginx/sites-enabled/foobar -> 49 | /etc/nginx/sites-available/foobar` is created. Note that if the 50 | `/etc/nginx/sites-enabled` directory doesn't exist the script 51 | creates it. 52 | 53 | 3. The script invokes `nginx -t` to test if the configuration is 54 | correct. If the test fails no symbolic link is created and an error 55 | is signaled. 56 | 57 | 4. If everything is correct now just reload nginx, in Debian based 58 | systems that means invoking `service nginx reload` (default 59 | startup program name is `service`). 60 | 61 | 5. Now point the browser to the newly configured host and everything 62 | should work properly assuming your configuration is sensible. 63 | 64 | 6. To disable the site just run `nginx_dissite foobar`. Reload nginx 65 | to update the running environment. 66 | 67 | ## Requirements 68 | 69 | The script is written in Bash and uses what I believe to be some Bash 70 | specific idioms. I never tested it in other shells. You're welcomed to 71 | try it in any other shell. Please do tell me how it went. 72 | 73 | It requires also [awk](http://en.wikipedia.org/wiki/AWK). The original 74 | `awk` (usually called BWK awk) from Bell Labs will do if you don't 75 | have [gawk](http://www.gnu.org/software/gawk) (Gnu awk). IN OS X and 76 | *BSD the former is the default `awk`. The script should work in *BSD, 77 | OS X and GNU/Linux. 78 | 79 | ## Command Completion 80 | 81 | There's a Bash script for automatic completion of sites to be 82 | enabled and disabled located in the `bash_completion.d` directory. 83 | 84 | To make use of it you should: 85 | 86 | 1. Source the script to Bash by issuing either `source 87 | nginx-ensite` or `. nginx-ensite`. 88 | 89 | 2. Now when you invoke `nginx_ensite` the sites under 90 | `/etc/nginx/sites-available` will appear as hypothesis for 91 | completion. For `nginx_dissite` you get all the sites listed in 92 | `/etc/nginx/sites-enabled` as possible completions. 93 | 94 | 3. To get the completion script to be sourced upon login please 95 | copy it to `/etc/bash_completion.d/` or whatever location your 96 | shell environment uses to place all the completion 97 | scripts. `/etc/bash_completion.d/` is the location in Debian 98 | (hence also in Ubuntu) of Bash completion scripts. 99 | 100 | ## Manual pages 101 | 102 | Two UNIX manual pages are included in the man directory. They should 103 | be copied to a proper directory in your system. Something along the 104 | lines of `/usr/share/man/man8` or `/usr/local/share/man/man8`. 105 | 106 | Here's an [online](http://github.perusio.org/nginx_ensite/) version of 107 | the manpage. 108 | 109 | 110 | ## Security & Trust 111 | 112 | The script is signed with my GPG key. Just do `gpg --keyserver 113 | keys.gnupg.net --recv-keys 4D722217`. Verify by issuing `gpg --verify 114 | nginx_ensite.sig`. 115 | 116 | ## Acknowledgments 117 | 118 | Thanks to the many people that have contributed to this script. You're 119 | the stuff Free Software is made of. 120 | -------------------------------------------------------------------------------- /bash_completion.d/nginx_ensite: -------------------------------------------------------------------------------- 1 | # nginx-ensite --- Bash completion function for nginx_ensite/nginx_dissite. 2 | 3 | # Copyright (C) 2010 António P. P. Almeida 4 | 5 | # Author: António P. P. Almeida 6 | 7 | # Permission is hereby granted, free of charge, to any person obtaining a 8 | # copy of this software and associated documentation files (the "Software"), 9 | # to deal in the Software without restriction, including without limitation 10 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | # and/or sell copies of the Software, and to permit persons to whom the 12 | # Software is furnished to do so, subject to the following conditions: 13 | 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | 17 | #!/bin/bash:wq 18 | 19 | # Except as contained in this notice, the name(s) of the above copyright 20 | # holders shall not be used in advertising or otherwise to promote the sale, 21 | # use or other dealings in this Software without prior written authorization. 22 | 23 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | # DEALINGS IN THE SOFTWARE. 30 | 31 | 32 | ## Handling of both enabled and available sites. 33 | _nginx_sites() { 34 | # Get the available or enabled sites for nginx. 35 | COMPREPLY=( $( compgen -W '$( command find /etc/nginx/$1 \ 36 | \( -type l -o -type f \) -printf "%P " 2>/dev/null \ 37 | | sed 's/[.]conf$//' )' -- $cur ) ) 38 | } 39 | 40 | _nginx_ensite() 41 | { 42 | local cur 43 | 44 | COMPREPLY=() 45 | cur=${COMP_WORDS[COMP_CWORD]} 46 | 47 | _nginx_sites sites-available 48 | } 49 | 50 | complete -F _nginx_ensite nginx_ensite 51 | 52 | _nginx_dissite() 53 | { 54 | local cur 55 | 56 | COMPREPLY=() 57 | cur=${COMP_WORDS[COMP_CWORD]} 58 | 59 | _nginx_sites sites-enabled 60 | } 61 | 62 | complete -F _nginx_dissite nginx_dissite 63 | -------------------------------------------------------------------------------- /bin/nginx_dissite: -------------------------------------------------------------------------------- 1 | nginx_ensite -------------------------------------------------------------------------------- /bin/nginx_ensite: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### nginx_ensite --- Bash script to enable or disable a site in nginx. 4 | 5 | ### Copyright (C) 2010, 2015 António P. P. Almeida 6 | 7 | ### Author: António P. P. Almeida 8 | 9 | ### Permission is hereby granted, free of charge, to any person obtaining a 10 | ### copy of this software and associated documentation files (the "Software"), 11 | ### to deal in the Software without restriction, including without limitation 12 | ### the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | ### and/or sell copies of the Software, and to permit persons to whom the 14 | ### Software is furnished to do so, subject to the following conditions: 15 | 16 | ### The above copyright notice and this permission notice shall be included in 17 | ### all copies or substantial portions of the Software. 18 | 19 | ### Except as contained in this notice, the name(s) of the above copyright 20 | ### holders shall not be used in advertising or otherwise to promote the sale, 21 | ### use or other dealings in this Software without prior written authorization. 22 | 23 | ### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | ### IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | ### FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | ### THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | ### LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | ### FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | ### DEALINGS IN THE SOFTWARE. 30 | 31 | SCRIPTNAME=${0##*/} 32 | 33 | ## The nginx binary. Check if we're root or not. If we are get the 34 | ## path to nginx. If not hardcode the path. 35 | if [ $(id -u) -eq 0 ]; then 36 | IS_ROOT=1 37 | NGINX=$(command -v nginx) || exit 1 38 | else 39 | STATUS=0 40 | NGINX=/usr/sbin/nginx 41 | fi 42 | 43 | ## Default value for the configuration directory. 44 | NGINX_CONF_DIR=/etc/nginx 45 | 46 | function print_usage() { 47 | echo "$SCRIPTNAME [-c default: /etc/nginx] [ -s default: service nginx reload] " 48 | } 49 | 50 | ## Extract the startup program name from a given argument. If it's a 51 | ## path to nginx then add the '-s reload' to the name. Otherwise just 52 | ## return the given argument. 53 | ## $1: the program name. 54 | ## Returns the proper startup program name, 55 | function get_startup_program_name() { 56 | local value="$1" 57 | if [[ $1 =~ [[:alnum:]/-]]+nginx$ ]]; then 58 | value="$1 -s reload" 59 | elif [ -z "$1" ]; then 60 | value="service nginx reload" 61 | else 62 | value=$1 63 | fi 64 | echo "$value" 65 | } 66 | 67 | ## The default start up program is service. 68 | STARTUP_PROGRAM_NAME=$(get_startup_program_name) 69 | 70 | ## Create the relative path to the vhost file. 71 | ## $1: configuration file name (usually the vhost) 72 | ## $2: available sites directory name (usually sites-available) 73 | ## Returns the relative path from the sites-enabled directory. 74 | function make_relative_path() { 75 | printf '../%.0s%s/%s' $(eval echo {0..$(expr length "${1//[^\/]/}")}) $2 $1 76 | } 77 | 78 | ## Checking the type of action we will perform. Enabling or disabling. 79 | ACTION=$(echo $SCRIPTNAME | awk '$0 ~ /dissite/ {print "DISABLE"} $0 ~ /ensite/ {print "ENABLE"} $0 !~ /(dis|en)site/ {print "UNKNOWN"}') 80 | 81 | if [ "$ACTION" == "UNKNOWN" ]; then 82 | echo "$SCRIPTNAME: Unknown action!" >&2 83 | print_usage 84 | exit 2 85 | fi 86 | 87 | ## Check the number of arguments. 88 | if [ $# -lt 1 -o $# -gt 5 ]; then 89 | print_usage >&2 90 | exit 3 91 | fi 92 | 93 | ## Parse the getops arguments. 94 | while getopts c:s: OPT; do 95 | case $OPT in 96 | c|+c) 97 | NGINX_CONF_DIR=$(realpath "$OPTARG") 98 | if [[ ! -d $NGINX_CONF_DIR ]]; then 99 | echo "$NGINX_CONF_DIR directory not found." >&2 100 | exit 3 101 | fi 102 | ;; 103 | s|+s) 104 | STARTUP_PROGRAM_NAME=$(get_startup_program_name "$OPTARG") 105 | ;; 106 | *) 107 | print_usage >&2 108 | exit 4 109 | ;; 110 | esac 111 | done 112 | shift $(( OPTIND - 1 )) 113 | OPTIND=1 114 | 115 | ## The paths for both nginx configuration files and the sites 116 | ## configuration files and symbolic link destinations. 117 | AVAILABLE_SITES_PATH="$NGINX_CONF_DIR/sites-available" 118 | ENABLED_SITES_PATH="$NGINX_CONF_DIR/sites-enabled" 119 | 120 | ## Check the number of arguments. 121 | if [ $# -ne 1 ]; then 122 | print_usage >&2 123 | exit 3 124 | else 125 | SITE_AVAILABLE=$(make_relative_path "$1" ${AVAILABLE_SITES_PATH##*/}) 126 | 127 | ## If enabling the 'default' site then make sure that it's the 128 | ## first to be loaded. 129 | if [ $1 == "default" ]; then 130 | SITE_ENABLED="$ENABLED_SITES_PATH/default" 131 | else 132 | SITE_ENABLED="$ENABLED_SITES_PATH/$1" 133 | fi 134 | ## Check if the directory where we will place the symlink 135 | ## exists. If not create it. 136 | [ -d ${SITE_ENABLED%/*} ] || mkdir -p ${SITE_ENABLED%/*} 137 | fi 138 | 139 | ## Check that the file corresponding to site exists if enabling or 140 | ## that the symbolic link exists if disabling. Perform the desired 141 | ## action if possible. If not signal an error and exit. 142 | case $ACTION in 143 | ENABLE) 144 | # Change to the directory where we will place the symlink so that we 145 | # see the relative path correctly. 146 | cd "${SITE_ENABLED%/*}"; 147 | if [ -r $SITE_AVAILABLE ]; then 148 | ## Test for a well formed configuration only when we are 149 | ## root. 150 | if [ -n "$IS_ROOT" ]; then 151 | echo "Pre-flight check..." 152 | $NGINX -t 153 | STATUS=$? 154 | fi 155 | if [ $STATUS -ne 0 ]; then 156 | exit 5 157 | fi 158 | ## Check the config testing status and if the link exists already. 159 | if [ -h $SITE_ENABLED ]; then 160 | ## If already enabled say it and exit. 161 | echo "$1 is already enabled." 162 | exit 0 163 | fi 164 | ln -s $SITE_AVAILABLE $SITE_ENABLED 165 | if [ -n "$IS_ROOT" ]; then 166 | echo "New config check..." 167 | $NGINX -t 168 | STATUS=$? 169 | fi 170 | if [ $STATUS -eq 0 ]; then 171 | echo "Site $1 has been enabled." 172 | # printf '\nRun "%s" to apply the changes.\n' $STARTUP_PROGRAM_NAME 173 | echo "Run '$STARTUP_PROGRAM_NAME' to apply the changes." 174 | exit 0 175 | else 176 | rm $SITE_ENABLED 177 | echo "$1 not enabled" 178 | exit 5 179 | fi 180 | else 181 | echo "Site configuration file $1 not found." >&2 182 | exit 6 183 | fi 184 | 185 | ;; 186 | DISABLE) 187 | if [ "$1" = "default" ] ; then 188 | if [ -h "$ENABLED_SITES_PATH/default" ] ; then 189 | SITE_ENABLED="$ENABLED_SITES_PATH/default" 190 | fi 191 | fi 192 | if [ -h $SITE_ENABLED ]; then 193 | rm $SITE_ENABLED 194 | echo "Site $1 has been disabled." 195 | # printf '\nRun "%s" to apply the changes.\n' $STARTUP_PROGRAM_NAME 196 | echo "Run '$STARTUP_PROGRAM_NAME' to apply the changes." 197 | exit 0 198 | else 199 | echo "Site $1 doesn't exist." >&2 200 | exit 7 201 | fi 202 | ;; 203 | esac 204 | -------------------------------------------------------------------------------- /doc/man/nginx_ensite.8.ronn: -------------------------------------------------------------------------------- 1 | nginx\_dissite, nginx\_ensite -- enable/disable an nginx site/virtual host 2 | ========================================================================== 3 | 4 | ## SYNOPSIS 5 | 6 | `nginx_ensite ` `-c` [ ] `-s` [ ] [ ]...
7 | `nginx_dissite` `-c` [ ] `-s` [ ] [ ]...
8 | 9 | ## DESCRIPTION 10 | 11 | This manual page documents briefly the nginx\_ensite 12 | and nginx\_dissite commands. 13 | 14 | nginx\_ensite is a script that **enables** the specified site which is included in a 15 | http block within the nginx configuration.
qIt does this by creating 16 | symlinks within the subdirectory `sites-enabled` of the nginx 17 | configuration directory (default: `/etc/nginx`). 18 | 19 | Likewise, nginx\_dissite disables a site by removing those 20 | symlinks. It is not an error to enable a site which is already 21 | enabled,
or to disable one which is already disabled. 22 | 23 | ## OPTIONS 24 | 25 | * `-c` 26 | Sets the nginx configuration directory to the given path (default: `/etc/nginx`). 27 | 28 | * `-s` 29 | Sets the nginx startup program name (default: `service`).
30 | Note that the program must be on the search path available to 31 | `nginx_ensite`/`nginx_dissite`.
If that not's the case then you 32 | need to pass the full path to the startup program executable. 33 | 34 | ## EXAMPLES 35 | 36 | Enable the default site: 37 | 38 | nginx_ensite default 39 | 40 | Disable the default site: 41 | 42 | nginx_dissite default 43 | 44 | Enable the example.org site: 45 | 46 | nginx_ensite example.org 47 | 48 | Enable the image serving vhost: 49 | 50 | nginx_ensite -c /home/luser/api/service/image/nginx img.example.org 51 | 52 | this corresponds to 53 | `/home/luser/api/service/image/nginx/sites-available/img.example.org`
54 | server configuration. This file will be symlinked to 55 | `/home/luser/api/service/image/nginx/sites-enabled/img.example.org`. 56 | 57 | ## FILES 58 | 59 | `/etc/nginx/sites-available`
60 | Default directory with files providing information on available sites. 61 | 62 | `/etc/nginx/sites-enabled`
63 | Default directory with links to the files in `sites-available` for enabled sites. 64 | 65 | ## SEE ALSO 66 | 67 | a2ensite(8), a2dissite(8), nginx(1) 68 | 69 | ## COPYRIGHT 70 | 71 | nginx_ensite is Copyright (C) 2010-2015 Antonio P. P. Almeida 72 | under the terms of a MIT license. 73 | 74 | ## AVAILABILITY 75 | 76 | The latest version of nginx_ensite is available from: 77 | [https://github.com/perusio/nginx_ensite](https://github.com/perusio/nginx_ensite). 78 | 79 | ## AUTHOR 80 | 81 | nginx_ensite was written by Antonio P. P. Almeida 82 | that also wrote the manual page based on the `a2ensite` manual page by 83 | Stefan Fritsch for the Debian GNU/Linux distribution. 84 | 85 | -------------------------------------------------------------------------------- /nginx_ensite.sig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/perusio/nginx_ensite/1d5d2f6851c0407a92db71262c1fc358ea873c88/nginx_ensite.sig -------------------------------------------------------------------------------- /share/man/man8/index.txt: -------------------------------------------------------------------------------- 1 | ## Manuals referenced on this project. 2 | a2ensite(8) http://man.cx/a2ensite 3 | a2dissite(8) http://man.cx/a2dissite 4 | nginx(1) http://man.cx/nginx 5 | -------------------------------------------------------------------------------- /share/man/man8/nginx_dissite.8: -------------------------------------------------------------------------------- 1 | .so man8/nginx_ensite.8 2 | -------------------------------------------------------------------------------- /share/man/man8/nginx_ensite.8: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn/v0.7.3 2 | .\" http://github.com/rtomayko/ronn/tree/0.7.3 3 | . 4 | .TH "NGINX_ENSITE" "8" "June 2015" "" "" 5 | . 6 | .SH "NAME" 7 | \fBnginx_ensite\fR \- enable/disable an nginx site/virtual host 8 | . 9 | .SH "SYNOPSIS" 10 | \fBnginx_ensite\fR \fB\-c\fR [ \fInginx configuration directory\fR ] \fB\-s\fR [ \fIstartup program name\fR ] [ \fIsite\fR ]\.\.\. 11 | . 12 | .br 13 | \fBnginx_dissite\fR \fB\-c\fR [ \fInginx configuration directory\fR ] \fB\-s\fR [ \fIstartup program name\fR ] [ \fIsite\fR ]\.\.\. 14 | . 15 | .br 16 | . 17 | .SH "DESCRIPTION" 18 | This manual page documents briefly the nginx_ensite and nginx_dissite commands\. 19 | . 20 | .P 21 | nginx_ensite is a script that \fBenables\fR the specified site which is included in a http block within the nginx configuration\. 22 | . 23 | .br 24 | qIt does this by creating symlinks within the subdirectory \fBsites\-enabled\fR of the nginx configuration directory (default: \fB/etc/nginx\fR)\. 25 | . 26 | .P 27 | Likewise, nginx_dissite disables a site by removing those symlinks\. It is not an error to enable a site which is already enabled, 28 | . 29 | .br 30 | or to disable one which is already disabled\. 31 | . 32 | .SH "OPTIONS" 33 | . 34 | .IP "\(bu" 4 35 | \fB\-c\fR \fInginx configuration directory\fR Sets the nginx configuration directory to the given path (default: \fB/etc/nginx\fR)\. 36 | . 37 | .IP "\(bu" 4 38 | \fB\-s\fR \fIstartup program name\fR Sets the nginx startup program name (default: \fBservice\fR)\. 39 | . 40 | .br 41 | Note that the program must be on the search path available to \fBnginx_ensite\fR/\fBnginx_dissite\fR\. 42 | . 43 | .br 44 | If that not\'s the case then you need to pass the full path to the startup program executable\. 45 | . 46 | .IP "" 0 47 | . 48 | .SH "EXAMPLES" 49 | Enable the default site: 50 | . 51 | .IP "" 4 52 | . 53 | .nf 54 | 55 | nginx_ensite default 56 | . 57 | .fi 58 | . 59 | .IP "" 0 60 | . 61 | .P 62 | Disable the default site: 63 | . 64 | .IP "" 4 65 | . 66 | .nf 67 | 68 | nginx_dissite default 69 | . 70 | .fi 71 | . 72 | .IP "" 0 73 | . 74 | .P 75 | Enable the example\.org site: 76 | . 77 | .IP "" 4 78 | . 79 | .nf 80 | 81 | nginx_ensite example\.org 82 | . 83 | .fi 84 | . 85 | .IP "" 0 86 | . 87 | .P 88 | Enable the image serving vhost: 89 | . 90 | .IP "" 4 91 | . 92 | .nf 93 | 94 | nginx_ensite \-c /home/luser/api/service/image/nginx img\.example\.org 95 | . 96 | .fi 97 | . 98 | .IP "" 0 99 | . 100 | .P 101 | this corresponds to \fB/home/luser/api/service/image/nginx/sites\-available/img\.example\.org\fR 102 | . 103 | .br 104 | server configuration\. This file will be symlinked to \fB/home/luser/api/service/image/nginx/sites\-enabled/img\.example\.org\fR\. 105 | . 106 | .SH "FILES" 107 | \fB/etc/nginx/sites\-available\fR 108 | . 109 | .br 110 | Default directory with files providing information on available sites\. 111 | . 112 | .P 113 | \fB/etc/nginx/sites\-enabled\fR 114 | . 115 | .br 116 | Default directory with links to the files in \fBsites\-available\fR for enabled sites\. 117 | . 118 | .SH "SEE ALSO" 119 | a2ensite(8), a2dissite(8), nginx(1) 120 | . 121 | .SH "COPYRIGHT" 122 | nginx_ensite is Copyright (C) 2010\-2015 Antonio P\. P\. Almeida under the terms of a MIT license\. 123 | . 124 | .SH "AVAILABILITY" 125 | The latest version of nginx_ensite is available from: \fIhttps://github\.com/perusio/nginx_ensite\fR\. 126 | . 127 | .SH "AUTHOR" 128 | nginx_ensite was written by Antonio P\. P\. Almeida that also wrote the manual page based on the \fBa2ensite\fR manual page by Stefan Fritsch for the Debian GNU/Linux distribution\. 129 | --------------------------------------------------------------------------------