This is a simple shell script that is designed to provision both nginx and node on your machine. I primarily wrote it for use with Vagrant and an example Vagrantfile
is included in the Gist as well.
Last active
June 12, 2022 19:01
-
-
Save DamonOehlman/5754302 to your computer and use it in GitHub Desktop.
Provisioning of node + nginx designed for use with vagrant shell provisioner. No need for chef, puppet.
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 | |
# node settings | |
NODE_VERSION=0.10.10 | |
NODE_SOURCE=http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.gz | |
# nginx settings | |
NGINX_VERSION=1.4.1 | |
NGINX_SOURCE=http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | |
# ensure we have all the required packages to install | |
echo "==> Checking Dependencies" | |
apt-get -y install git libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev > /dev/null | |
apt-get -y upgrade > /dev/null | |
# if we don't have the latest node version, then install | |
echo "==> Checking Node version $NODE_VERSION installed"; | |
if [ ! -e /opt/node/$NODE_VERSION ] | |
then | |
echo "==> Installing Node.js version $NODE_VERSION" | |
echo "Downloading node source from $NODE_SOURCE" | |
cd /usr/src | |
wget --quiet $NODE_SOURCE | |
tar xf node-v$NODE_VERSION.tar.gz | |
cd node-v$NODE_VERSION | |
# configure | |
./configure --prefix=/opt/node/$NODE_VERSION | |
# make and install | |
make | |
make install | |
fi | |
# create node application links | |
ln -sf /opt/node/$NODE_VERSION/bin/node /usr/bin/node | |
ln -sf /opt/node/$NODE_VERSION/bin/npm /usr/bin/npm | |
# if we don't have nginx install, then install | |
echo "==> Checking Nginx version $NGINX_VERSION installed" | |
if [ ! -e /opt/nginx-$NGINX_VERSION ] | |
then | |
echo "==> Installing Nginx $NGINX_VERSION"; | |
echo "Downloading nginx source from $NGINX_SOURCE"; | |
cd /usr/src | |
wget --quiet http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | |
tar xf nginx-$NGINX_VERSION.tar.gz | |
cd nginx-$NGINX_VERSION | |
# configure nginx | |
./configure --with-pcre --with-http_ssl_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --prefix=/opt/nginx-$NGINX_VERSION | |
# make nginx and install | |
make | |
make install | |
fi | |
# create the appropriate nginx links | |
ln -sf /opt/nginx-$NGINX_VERSION /opt/nginx | |
# ensure we have services setup | |
echo "==> Checking service configurations"; | |
if [ ! -e /etc/init/nginx.conf ] | |
then | |
echo "==> Installing nginx service"; | |
fi |
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
# Template vagrant configuration file for rtc.io server | |
Vagrant.configure("2") do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "ubuntu-12.04" | |
config.vm.box_url = "http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box" | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# config.vm.network :forwarded_port, guest: 80, host: 8080 | |
# Create a private network, which allows host-only access to the machine | |
# using a specific IP. | |
config.vm.network :private_network, ip: "192.168.33.10" | |
# provision using the shell provisioner | |
config.vm.provision :shell do |shell| | |
shell.inline = "curl -s https://gist.github.com/DamonOehlman/5754302/raw/provision-nginx-node.sh | sh" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment