Created
June 20, 2011 19:04
-
-
Save nhocki/1036310 to your computer and use it in GitHub Desktop.
linode stack script to setup a headless ubuntu linode w/ RVM, MySQL, Nginx, and Unicorn
This file contains hidden or 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 | |
#<udf name="hostname" label="System Host Name"> | |
#<udf name="adminuser" default="admin" label="Admin user name"> | |
#<udf name="adminpassword" label="Admin user password"> | |
#<udf name="deployuser" default="deploy" label="Deploy user name"> | |
#<udf name="deploypassword" label="Deploy user password"> | |
#<udf name="mysql_password" label="MySQL Password"> | |
source <ssinclude StackScriptID=1> | |
system_update | |
goodstuff | |
################# | |
# Admin User | |
################# | |
useradd -s /bin/bash --user-group --groups sudo --create-home $ADMINUSER | |
echo "$ADMINUSER:$ADMINPASSWORD" | chpasswd | |
################# | |
# Deploy User | |
################# | |
useradd -s /bin/bash --user-group --groups www-data --create-home $DEPLOYUSER | |
echo "$DEPLOYUSER:$DEPLOYPASSWORD" | chpasswd | |
################# | |
# System | |
################# | |
echo $HOSTNAME > /etc/hostname | |
echo -e "\n127.0.0.1 $HOSTNAME.local $HOSTNAME\n" >> /etc/hosts | |
service hostname start | |
######################################## | |
# Install the required dependencies | |
######################################## | |
apt-get -y install build-essential \ | |
libxml2-dev \ | |
libxslt-dev \ | |
libcurl4-openssl-dev \ | |
libreadline-dev \ | |
libncurses5-dev \ | |
libpcre3-dev \ | |
libmysqlclient-dev \ | |
libsqlite3-dev \ | |
bison \ | |
git-core | |
################# | |
# Install rvm | |
################# | |
bash < <( curl -L http://bit.ly/rvm-install-system-wide ) | |
. "/usr/local/rvm/scripts/rvm" | |
source /usr/local/lib/rvm | |
########################### | |
# Setup RVM environment | |
########################### | |
cat >> /etc/profile << EOF | |
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then | |
. "$HOME/.rvm/scripts/rvm" | |
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then | |
. "/usr/local/rvm/scripts/rvm" | |
fi | |
source /usr/local/lib/rvm | |
EOF | |
################################### | |
# Install, and set REE to default | |
################################### | |
rvm install ree | |
rvm use --default ree | |
################# | |
# Install Rails | |
################# | |
gem install rails bundler --no-ri --no-rdoc | |
usermod -a -G rvm $DEPLOYUSER | |
################# | |
# Install Nginx | |
################# | |
NGINX_URL="http://sysoev.ru/nginx/nginx-0.8.54.tar.gz" | |
NGINX_TGZ="nginx-0.8.54.tar.gz" | |
NGINX_DIR="nginx-0.8.54" | |
wget $NGINX_URL | |
tar zvxf $NGINX_TGZ | |
cd $NGINX_DIR | |
./configure --prefix=/opt/nginx | |
make | |
make install | |
curl -L http://bit.ly/f7QYpy > /opt/nginx/conf/nginx.conf # Nginx Base Config | |
curl -L http://bit.ly/hR889Q > /opt/nginx/sbin/nginx.reload.sh # Nginx Reload Script ( Used for Capistrano deployments ) | |
chmod +x /opt/nginx/sbin/nginx.reload.sh # Make Executable | |
/opt/nginx/sbin/nginx # Start the server | |
# Add the cron | |
cat > /etc/cron.d/nginx << EOF | |
*/5 * * * * root /opt/nginx/sbin/nginx.reload.sh | |
EOF | |
service cron restart | |
################# | |
# App Dir | |
################# | |
mkdir -p /opt/apps | |
chown -R root:www-data /opt/apps | |
chmod -R 2775 /opt/apps | |
chmod -R +s /opt/apps | |
################# | |
# Install MySQL | |
################# | |
mysql_install "$MYSQL_PASSWORD" && mysql_tune 40 | |
############################### | |
# Disable Root Login | |
############################### | |
sudo passwd -l root | |
############################### | |
# Restart Installed Services | |
############################### | |
restartServices |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment