Running DirectAdmin On Amazon EC2 Linux- Solved!

We were able to install DirectAdmin (a Web hosting control panel) on Amazon’s Elastic Compute Cloud, branded as EC2. We would like to share the steps required to build a working instance of DirectAdmin on an Amazon server. First, I would like to personally thank Mark from DirectAdmin for being so accommodating and granting us a trial license. His help is very much appreciated! Keep in mind that UNIXY‘s truly fully managed service goes above and beyond. We take business dreams and make them a reality.

Before we list the requirements, it is important to note that EC2 instances are Xen Virtual Machines. We encountered some issues running DA on the “Small” Amazon instances. The issues are related to 64-bit mode library mismatches. The only instances to be able to run DirectAdmin out of the box are of type “Large” and better. They are more expensive but ideal for this configuration.

Here are the requirements:

  • Instance of type Large
  • Linux CentOS 5 image
  • One elastic (which is another word for static) IP address

Go ahead and bring up the node as you would normally do. Be sure to remove all extra software that comes pre-installed with the CentOS 5 image. Otherwise, it will break DirectAdmin. If in doubt, follow the instructions on the DirectAdmin Install page:

http://www.directadmin.com/install.html

Once logged in as root, go ahead and download the DirectAdmin install tarball:

# wget http://www.directadmin.com/setup.sh

By default, the licensing scheme of DirectAdmin makes it that setup.sh binds to the licensed IP address. Here’s how the license verification command looks like:

$BIN_DIR/wget $WGET_OPTION -O $DA_PATH/update.tar.gz –bind-address=$IP https://www.directadmin.com/cgi-bin/daupdate?uid=$CID\&lid=$LID

But as you know, EC2 instances are 1:1 private:public NAT. Which means that the license check step will fail and the DA install won’t start. To avoid this chicken-and-egg problem, we are going to tell setup.sh to not bind to any IP address but to simply connect to the DA licensing server using the elastic external IP address, which it will do by default. Go ahead and run this command against the setup.sh file:

# sed -i 's/--bind-address=\$IP//;' setup.sh

Before we run setup.sh, we need to trick the setup script to think that the external IP address is “attached” to the server. Here’s how:

# ifconfig eth0:0 inet 1.1.1.1 netmask 255.255.255.255 up

Be sure to replace the IP address 1.1.1.1 with your elastic IP. Then simply run setup.sh:

# cd /usr/local/directadmin/scripts; while [ true ]; do sed -i 's/--bind-address=\$IP//; s/--bind-address=\${3}//;' *.sh > /dev/null > 2&>1; sleep 10; done & sh setup.sh 11111 22222 vpslux.com eth0:0 1.1.1.1

Woaah! Wait a minute! What is that!? OK, let’s break it down. The DA scripts directory gets unpacked into the server after you run setup.sh. It dumps a list of scripts that are used by DA to setup accounts, domains, etc. Some scripts use the same –bind-address flag. Having that flag in those scripts breaks DA. the one-line script “while [ true ]; do sed -i ‘s/–bind-address=\$IP//; s/–bind-address=\${3}//;’ *.sh; sleep 10; done” simply goes to that directory and removes the flag.

The trick being DA attempts to run some of those scripts while setup.sh is running. So it’s important to have the sed script run in parallel during the installation. Once the setup.sh is done running, we’ll kill the job (or reboot per the final step). The arguments supplied to setup.sh are in this format

# setup.sh <ClientID> <LicenseID> <Hostname> <Interface> <ExternalIP>

Be sure to replace those values accordingly. Once the install finishes, simply reboot the VM:

# reboot

That’s all folks. Enjoy!

June 20, 2009 • Tags: , , , , , • Posted in: Challenge

5 Responses to “Running DirectAdmin On Amazon EC2 Linux- Solved!”

  1. Running DirectAdmin On Amazon EC2 Linux- Solved! | Web 2.0 Designer - June 20, 2009

    [...] Read this article: Running DirectAdmin On Amazon EC2 Linux- Solved! [...]

  2. Scott Gaspar - October 28, 2009

    Thanks for the great article.

    Quick question about DA-APIs.http://www.directadmin.com/api.html

    Have you confirmed that these GET/POST requests work with Amazon EC2? We are looking at this type of solution and I am curious if you’ve tested these, specifically around user provisioning.

    Thanks!

    Scott

  3. John Paul Sheridan - December 1, 2009

    Hi,

    When you state static IP address in your list of requirements are you referring to my statis public IP or the static private internal IP that my public is translated to using NAT?

    I’m trying to get this working but unsure if I’m following it properly or putting the right IP addresses in. Plus I don’t have a host name. This server is for development/testing. Should I enter my public IP as the hostname or make one up?

    Apologies for my ignorance. I’m new enough to web programming, primarily a desktop programmer.

    Thanks,
    JP

  4. UNIXy - December 2, 2009

    The static public IP is the IP facing the Internet and not the private IP. As for the host name, you can just make one up but be sure to save it (hostname server.hostname.com).

    Cheers

  5. JS - May 11, 2010

    Anybody face this issue after reboot the DA doesn’t work?

Leave a Reply

Comment moderation is enabled. Your comment may take some time to appear.

Spam protection by WP Captcha-Free


Search The Blog







Categories