
Backstory
My problems began when I stumbled upon the fact that I could no longer use my old desktop as a development server. Behemoth cable companies being what they are, I realized that mine was deviously blocking port 80, but only outside of a ~50 mile radius of my home. That Thanksgiving week with the family a few hundred miles away was a bummer.
I needed some hosting. And I needed something that I could play with, outside of the confines of even what the more configurable hosting services had to offer. I needed tomcat and an apache tomcat connector. I needed svn. I needed cron and some executable .jars. I needed.. xen.
Linode or Slicehost seemed to be the name of the game. They looked comparable. Expensive, but with a variety of features. On the other hand, I always wanted the geek cred of setting up a server without help. I went with pgrmr.com.
Now, I’m a programmer by trade. I like the command line, but I spend my days in Eclipse. Would I be able to handle prgmr? After I saw the prices, I knew I had to try.
Enter Prgmr
I signed up for the 512mb/80gb transfer for $12/mo. Upside: cheap, cheap, cheap. Downside: expect to do everything yourself. This includes DNS and mail. Fortunately, I still have a dreamhost account for some freelance and such (including this blog). I kept my DNS on dreamhost and pointed domains I wanted over to my prgmr.com vps. I used google apps and their gmail for a mailserver. This was fairly easy, but I may do a post on it in the future.
After I received the welcome email, I was able to select the distro I desired (ubuntu) and gave him a private key and I was on my way.
Setting up users
First things first, what you’re given to log into is the xen hypervisor. It’s a launchpad to your vps as root, essentially, with other options like restart the box. Once you’re in as root, set up some users, then get out. If you set up a few admin accounts so you can ssh into your box and use bash just like any other ubuntu machine. The Xen Hypervisor isn’t really conducive to getting work done (has some issues).
In Ubuntu, it’s like this
The adduser command prompts you for the password and such.
There is a similar command, useradd. I learned the hard way: useradd does not create .bash_profile and .bashrc for that user. Hence, all the nice bash colors and autocomplete and such do not happen. If you find yourself in the same predicament, the default for these files exist in /etc/skel. I was able to copy them over to my new user’s home directory successfully.
Setting up Apache and Tomcat
From this point, you can essentially follow any of the FAQs out there to set up your web servers. As for myself, I needed Apache httpd, mysql, and tomcat. I ended up installing apache httpd from the ubuntu repositories. For Tomcat, I downloaded the binaries. I had problems with the repository version before, and I’m used to having all the server files in the same place.
Apache httpd
sudo apt-get install apache2;
Server config files:
Logs:
Default public document root:
Tomcat
I followed the instructions from here.
Starting and stopping the servers:
sudo /etc/init.d/tomcat [start,stop,restart]
sudo /etc/init.d/apache2 [start,stop,restart]
For a server connector, I chose mod_proxy_ajp. I’ve used mod_proxy and mod_jk before, so I tried something new. I actually think it’s my favorite now. The only thing I don’t like is that sometimes if Tomcat goes down, Apache2 needs to be kicked to get the connection up and going again. More to come on server connectors in a future post.
Mysql
Mysql is the easiest of the bunch.
sudo apt-get install mysql-server
During the installation it will prompt you for a password for the root user. It’s very important to remember this one. When you’re done, you can log in with
and providing the password at the prompt. You’ll get a fully interactive mysql shell.
If you’re new to using the command line tool like I was, here are some commands to get you started:
Display all tables:
Create a database:
create database the_database;
Switch to using the database you created:
From this point you could execute sql in the console window, like so:
Display all tables and some info about them:
Display all columns in the table and their type:
Cred Established
All in all, it went very well, and I now consider myself a card carrying sysadmin. Well, any sysadmin worth their salt will still probably despise my lack of blowfish t-shirts and perl skillz, but oh well. I heartily recommend prgmr if you want to save a few bucks on hosting. As far as uptime, I cannot say for sure. I’ve never had any problems though.
Addendum
Is a 512mb “slice” good enough for the memory hog that is tomcat? I think so. Tomcat does end creep up from 30% of virtual memory to about 45-50%, but as I only use the box for my tomcat server, it’s no biggie. I’ve yet to do any memory profiling, but I’ve had tomcat up and running for a good month without a crash. I may do another blog on memory in the future.