Skip to content

Instantly share code, notes, and snippets.

@ngerakines
Created October 18, 2009 21:27
Show Gist options
  • Select an option

  • Save ngerakines/212865 to your computer and use it in GitHub Desktop.

Select an option

Save ngerakines/212865 to your computer and use it in GitHub Desktop.
README FIRST
The name of the slice and hostname is 'CAG', change all instances of that to whatever your hostname is.
The erlang package on yum is not latest and does not install sources. You'll need the ncurses-devel and openssl-devel packages to build the otp/erlang source.
If you are going to connect multiple slices/nodes be sure to contact Slicehost support for internal IP addresses for all of your nodes. Then, be sure to have your nodes connect with each other over those IPs. It'll save you bandwidth and internal traffic doesn't count against your monthly plan. Also, be absolutely sure to do any data transfers (MySQL, CouchDB, MongoDB, scp, etc) over those IPs.
What I do is run lighttpd as a dumb hostname/ip proxy to internal services. I'll run lighttpd on port 80 and then all of the other services on ports internal IPs and route requests to them based on hostname. I've included my lighttpd config and the iptables config to help out.
# as root
passwd
useradd yourusername
passwd yourusername
yum install sudo
vim /etc/sudoers
> yourusername ALL=(ALL) NOPASSWD: ALL
# exit, ssh back in as 'yourusername'
sudo yum install vim-enhanced sudo screen which unzip gcc gcc-c++ autoconf automake libtool subversion doxygen rpm-build zip make ncurses-devel openssl-devel Django MySQL-python protobuf-python mysql-server ntp
sudo yum install lighttpd.x86_64 lighttpd-fastcgi.x86_64
sudo vim /etc/ntp.conf
sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
/usr/bin/rdate -s time-a.nist.gov
/usr/bin/rdate -s time-a.nist.gov
sudo /etc/init.d/mysqld start
/usr/bin/mysqladmin -u root password 'asd123'
/usr/bin/mysqladmin -u root -h CAG password 'asd123'
cd tmp
wget http://www.erlang.org/download/otp_src_R13B01.tar.gz
wget http://www.monkey.org/~provos/libevent-2.0.2-alpha.tar.gz
tar zxf libevent-2.0.2-alpha.tar.gz
cd libevent-2.0.2-alpha && ./configure && make && sudo make install
tar zxf otp_src_R13B01.tar.gz
cd otp_src_R13B01 && ./configure && make && sudo make install
git clone git://github.com/ngerakines/mochiweb.git ngerakines-mochiweb
git clone git://github.com/ngerakines/erlang_protobuffs.git ngerakines-erlang_protobuffs
git clone git://github.com/ngerakines/etap.git ngerakines-etap
git clone git://github.com/ngerakines/mcerlang.git ngerakines-mcerlang
git clone git://github.com/ngerakines/erlang_facebook.git ngerakines-erlang_facebook
cd ngerakines-mochiweb && make && sudo make install
cd ngerakines-erlang_protobuffs && make && sudo make install
cd ngerakines-etap && make && sudo make install
cd ngerakines-erlang_facebook && make && sudo make install
sudo vim /etc/lighttpd/lighttpd.conf
> update lighttpd config from lighttpd.conf
sudo vim /etc/sysconfig/iptables
> update iptables config from iptables
sudo /etc/init.d/iptables restart
sudo /etc/init.d/lighttpd restart
# /etc/sysconfig/iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
COMMIT
# /etc/lighttpd/lighttpd.conf
server.modules = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_proxy",
"mod_accesslog" )
server.document-root = "/var/www/lighttpd/"
server.errorlog = "/var/log/lighttpd/error.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
mimetype.assign = (
".rpm" => "application/x-rpm",
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
...
".tar.bz2" => "application/x-bzip-compressed-tar",
"" => "application/octet-stream",
)
accesslog.filename = "/var/log/lighttpd/access.log"
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
server.pid-file = "/var/run/lighttpd.pid"
server.username = "lighttpd"
server.groupname = "lighttpd"
$HTTP["host"] =~ "(^|\.)iplaywar\.socklabs\.com" {
proxy.server = (
"" => (
"can" => (
"host" => "127.0.0.1",
"port" => 5005,
"fix-redirects" => 1
)
)
)
}
include_shell "find /etc/lighttpd/conf.d -maxdepth 1 -name '*.conf' -exec cat {} \;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment