Note: A large part of this is taken from Victor Kane's article on Awebfactory about setting up Drupal on a fresh Linode, but I've documented some other things here and did some things a little differently than he did, so I figured it'd be worth writing up a post on the process. I've kept the details thin here in places where Victor's notes are more than satisfactory, but I've made sure to note where that happens.
Update: Be sure to check out part 2 of this article, as well.
I've spent the last several months of my off-work hours plugging away at helping the folks over at Gamers With Jobs get rolling with an upgraded version of Drupal, and in the process we decided to move from a shared hosting environment to a place where we've got a lot more control over performance and site configuration. In the meantime, Victor Kane's article on getting Drupal up and running on a Linode came across my RSS reader and provided the kick in the pants I needed to really investigate it. I looked at several VPS options, but in the end Linode seemed to be the best. They offered a seven day money back guarantee, which honestly isn't much, but it was long enough for me to feel comfortable giving it a shot without being out sixty bucks, so I decided to try it out.
Signing up for a Linode account
In spite of all my enterprise-level work at ASU, Gamers With Jobs is one of the most heavily trafficked sites I've ever worked on, so I wanted to choose a hosting option with plenty of RAM and enough monthly transfer to handle the load. I decided to go for a Linode 1080, completed the registration process and had a virtual machine ready to work on within, literally, minutes.
The very slick Linode dashboard reported back to me that the machine was ready to go, so I booted it up and began what I expected to be a fairly painful process - installing the operating system. Here's where I have to make a confession... I've never done this stuff before. That doesn't mean I'm a complete newbie when it comes to working with Linux - I spend pretty much the bulk of every day immersed in the terminal - but I've never run a system at this level before. I was completely confident I'd be able to do everything I needed to, but I was bracing myself for hours of learning. I even asked a couple of good friends if they'd be willing to help out in a bind (they agreed without hesitation, which is why they're such good friends, I guess).
Installing Ubuntu 7.10
With this in mind, I embarked on my journey to install Ubuntu. I had done quite a bit of research on which distribution I should use for the server, and Ubuntu seemed like the best balance between ease of use and functionality. At this point, I was staring at the Linode dashboard, which I figured was deceiving me with how simple it made the next step look. It told me to click over to the distro wizard and choose which package to proceed with. I clicked, saw Ubuntu 7.10 as an option and with guarded excitement, clicked to proceed.
So, as I was saying before, the Linode dashboard is really slick and has an auto-updating "job queue" view that lets you follow some of the server processes you wouldn't normally be able to track remotely, such as disk creation, reboots, OS installs, etc. Well, what to my wondering eyes should I see but this view updating itself rather quickly, telling me that it's creating a disk image and has the OS installation pending. Within about 10 minutes, the dashboard had updated to tell me the everything was ready to go (there are a couple of brief, well explained steps in here where you set your root password, etc.). I couldn't believe it was really this easy, but I clicked over to the "Remote Access" tab of the dashboard, grabbed my IP address and shelled in effortlessly.
At this point, I'm essentially following Victor's steps for a while, so if anything is unclear, jump over there for details.
Set the hostname
echo jeffbeeman.com > /etc/hostname
Reboot via the Linode dashboard...
Configuring package management
Setup package management by modifying /etc/apt/sources.list. Essentially I've added the gutsy universe and multiverse repositories and enabled the security updates for those repositories. Here's my current sources.list:
deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted
deb-src http://archive.ubuntu.com/ubuntu/ gutsy main restricted
## Uncomment the following two lines to add software from the 'universe'
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
# deb http://archive.ubuntu.com/ubuntu/ gutsy universe
# deb-src http://archive.ubuntu.com/ubuntu/ gutsy universe
deb http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted
## Added by email@example.com on 12/26/2007
## Universe / Multiverse
deb http://archive.ubuntu.com/ubuntu gutsy universe multiverse
deb-src http://archive.ubuntu.com/ubuntu gutsy universe multiverse
## Universe / Multiverse updates
deb http://archive.ubuntu.com/ubuntu gutsy-security universe multiverse
deb-src http://archive.ubuntu.com/ubuntu gutsy-security universe multiverse
deb http://archive.ubuntu.com/ubuntu gutsy-updates universe multiverse
deb-src http://archive.ubuntu.com/ubuntu gutsy-updates universe multiverse
Run an update / upgrade
Installing Apache, MySQL and PHP
# Install mysql
apt-get install mysql-server
# Install Apache
apt-get install apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert
# Install PHP
apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
# Restart Apache
Making sure Apache and PHP work
For this, I simply setup a basic phpinfo() file, just to make sure Apache, PHP and all necessary libraries are ready to go. Since Apache is setup to host files out of /var/www by default, I just threw it in there.
echo "" > /var/www/info.php
Then, I opened up a browser and visited http://188.8.131.52/info.php (where 184.108.40.206 is the real IP address). I saw the PHP info stuff, and knew I was ready to rock.
Setting up the first virtual host
My trial run was to setup a fresh Drupal install using the jeffbeeman.com domain name, so I opened up /etc/apache2/httpd.conf (which was empty) and added my first virtual host:
Allow from all
...and make the folder for the site to live:
I hadn't seen Ubuntu's (Debian's?) way of setting up Apache 2 before, but it's really quite slick. Enabling new mods, assuming they're installed, is a snap. Here's how I enabled mod_rewrite:
Since I want PHP to be able to send email, this is a necessity.
apt-get install sendmail
Updating PHP settings
Next, I opened up /etc/php5/apache2/php.ini and updated the sendmail path and upload max file size to my preferred default.
sendmail_path = /usr/sbin/sendmail -i -t
upload_max_filesize = 8M
Finally, I did one last Apache restart to ensure everything was set.
Creating and granting privileges to the Drupal database
mysql -u root -p
GRANT ALL PRIVILEGES ON
Download and install Drupal 5.5
tar xzf drupal-5.5.tar.gz
# Copy to the virtual host directory
cp -R * /usr/local/www/jeffbeeman.com/
cp .htaccess /usr/local/www/jeffbeeman.com/
# Update settings.php permissions to allow installer to access it
chmod 666 settings.php
Since I haven't touched a web browser since I made sure my info.php file worked, I need to tweak my hosts file a bit so that I can view jeffbeeman.com as hosted on my new site. Since I don't yet want to go through the trouble of actually changing the IP that the domain name is looking at, I'll just update my hosts file to point at the right IP. In OS X, that file is /etc/hosts. I opened it up and added:
Now, any time I go to jeffbeeman.com, I'll see the Linode hosted site. Just for reference, www.jeffbeeman.com still goes to the old server, so I still have access to the live site.
Now that that's taken care of, I can open up a browser to http://jeffbeeman.com and install Drupal. After the install, I changed permissions on settings.php back to read-only and created and set permissions on the files folder.
chmod 644 sites/default/settings.php
chmod 777 files
Total work time to get to this point: 1.5 hours
I'll I can say is, "Damn." That was far faster than I expected the process to go.