Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added a README and signed the script for security reasons.
- Loading branch information
António P. P. Almeida
committed
Aug 10, 2010
1 parent
4f14f19
commit 9bbefb7
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/nginx_dissite | ||
/nginx_ensite.sig |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
* nginx_ensite and nginx_dissite for quick virtual host enabling and disabling | ||
|
||
** Description | ||
|
||
This is a shell (Bash) script that replicates for [[http://wiki.nginx.org][nginx]] the [[http://debian.org][Debian]] | ||
=a2ensite= and =a2dissite= for enabling and disabling sites as virtual | ||
hosts in Apache 2.2. | ||
|
||
The original =a2ensite= and =a2dissite= is written in | ||
Perl. =a2dissite= is a symbolic link to =a2ensite=. Here I followed | ||
the same approach, i.e., =nginx_dissite= is a symbolic link to | ||
=nginx_ensite=. | ||
|
||
** Installation | ||
|
||
Just drop the script and the symbolic link in =/usr/sbin= or other | ||
location appropriate for your system. Meaning: =cp nginx_* /usr/sbin=. | ||
That's it you're done. | ||
|
||
Note that the script assumes a specific file system topology for your | ||
=nginx= configuration. Here's the rundown: | ||
|
||
1. All virtual hosts configuration files should be under | ||
=/etc/nginx/sites-available=. For example the virtual host | ||
=foobar= is configured through a file in =/etc/sites/available=. | ||
|
||
2. After running the script with =foobar= as argument: =nginx_ensite | ||
foobar=. A symbolic link =/etc/nginx/sites-enabled/foobar -> | ||
/etc/nginx/sites-available/foobar= is created. | ||
|
||
3. The script invokes =nginx -t= to test if the configuration is | ||
correct. If the test fails no symbolic link is created and an error | ||
is signaled. | ||
|
||
4. If everything is correct now just reload nginx, in Debian based | ||
systems that means invoking =/etc/init.d/nginx reload=. | ||
|
||
5. Now point the browser to the newly configured host and everything | ||
should work properly assuming your configuration is sensible. | ||
|
||
6. To disable the site just run =nginx_dissite foobar=. Reload nginx | ||
to update the running environment. | ||
|
||
|
||
** Requirements | ||
|
||
The script is written in Bash and uses what I believe to be some Bash | ||
specific idioms. I never tested it in other shells. You're welcomed to | ||
try it in any other shell. Please do tell me how it went. | ||
|
||
It requires also [[http://en.wikipedia.org/wiki/AWK][awk]]. The original =AWK= (usually called BWK awk) from | ||
Bell Labs will do if you don't have [[http://www.gnu.org/software/gawk/][gawk]] (Gnu awk). IN OS X and *BSD | ||
the former is the default =awk=. The script should work in *BSD, OS X | ||
and GNU/Linux. | ||
|
||
|
||
** Security & Trust | ||
|
||
The script is signed with my GPG key. Just do =gpg --keyserver | ||
keys.gpg.net --recv-keys 4D722217=. Verify by issuing =gpg --verify | ||
nginx_ensite.sig=. |