Skip to content

Instantly share code, notes, and snippets.

@Dirrk
Last active October 31, 2015 17:26
Show Gist options
  • Save Dirrk/c3d406d6bc6e7f51b6bc to your computer and use it in GitHub Desktop.
Save Dirrk/c3d406d6bc6e7f51b6bc to your computer and use it in GitHub Desktop.
Install nginx and node
#!/bin/bash
# This installs nginx and node under /app
NODE_VERSION=4.2.1
if [ "$UID" -ne 0 ]
then echo "Please run as root"
exit
fi
if [ ! -e /usr/bin/gcc ] || [ ! -e /usr/bin/make ]; then
echo gcc or make not installed going to install dev tools in 5 seconds press ^C to exit
sleep 6
yum -y groupinstall 'Development Tools'
fi
if [ ! -e /opt/nginx ]; then
mkdir /opt/nginx
cd /opt/nginx
wget http://nginx.org/download/nginx-1.6.0.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
wget https://www.openssl.org/source/openssl-1.0.1i.tar.gz
tar -xf nginx-1.6.0.tar.gz
tar -xf pcre-8.35.tar.gz
tar -xf zlib-1.2.8.tar.gz
tar -xf openssl-1.0.1i.tar.gz
mkdir -p nginx-1.6.0/modules
mv pcre-8.35 nginx-1.6.0/modules/
mv zlib-1.2.8 nginx-1.6.0/modules/
mv openssl-1.0.1i nginx-1.6.0/modules/
cd nginx-1.6.0
./configure --with-pcre=./modules/pcre-8.35/ --with-zlib=./modules/zlib-1.2.8/ --with-openssl=./modules/openssl-1.0.1i --with-http_ssl_module --prefix=/app/nginx
make
make install
else
echo "nginx was already installed"
fi
if [ ! -e /opt/node ]; then
mkdir -p /app
mkdir /opt/node
cd /opt/node
wget http://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz
tar -xf node-v${NODE_VERSION}-linux-x64.tar.gz
cd node-v${NODE_VERSION}-linux-x64
if [ -e /usr/bin/node ]; then
rm /usr/bin/node
fi
if [ -e /usr/bin/npm ]; then
rm /usr/bin/npm
fi
if [ -e /app/node ]; then
rm /app/node
fi
ln -s /opt/node/node-v${NODE_VERSION}-linux-x64 /app/node
ln -s /app/node/bin/node /usr/bin/node
ln -s /app/node/bin/npm /usr/bin/npm
else
echo "node was already installed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment