Posts Tagged tutorial

Serving a GWT Application with an Embedded Jetty Server

For a new project I am interested in starting, I want to serve a GWT application with an embedded Jetty server. I wasn’t sure how to go about doing so, but it turns out it’s easier than I could ever have expected! Check it out below (or, for you folks viewing this in an RSS feed, at http://gist.github.com/346622).

You do, of course, need the Jetty jars (I used the ones from the ‘lib’ folder in the Jetty distribution) in your classpath.

, , , , , , ,

2 Comments

Easily Forward Requests from One Domain to Another

My WoW blog used to be located at wow.binarymuse.net; now it’s at www.thealtoholic.com. I ignorantly inserted images and links as absolute paths instead of relative ones–now all those URLs are dead, because wow.binarymuse.net is gone. Instead of going back and editing all my old URLs, here’s what I did:

1. If your old URL was a subdomain, as mine was (wow.binarymuse.net), add a new A record in the zone for your old domain (in my case, in the zone binarymuse.net, I added an A record for ‘wow’ pointing to my IP address).

2. Add a new ServerAlias in the VirtualHost entry for your new domain. In my case, I added the ‘ServerAlias wow.binarymuse.net’ to the VirtualHost entry for thealtoholic.com.

That’s it! Once everything propogated out, all my http://wow.binarymuse.net/something/somethingelse URLs automatically forwarded to http://www.thealtoholic.com/something/somethingelse!

, , , ,

No Comments

Developing a Site with VirtualHosts but No Domain

In the end, this post will be about how to develop a site on a box that uses Apache’s VirtualHost if you don’t yet have a domain set up for that particular VirtualHost, or in my case, already have one going and are going to switch it over when you’re done. But, before then, this particular little tutorial deserves some backstory.

In the Beginning

In the past, I had a VPS. I had a lot of trouble with said VPS–or, more accurately, the company that sold me the VPS. I won’t name the company, but they did a big BSD to RedHat switch and forced everyone to backup all their data and, basically, start over on a fresh box. The new boxes had Virtuozzo and Plesk, but cost more. Over time, I learned to dislike Plesk and the limits it placed on what I could do. Oh, I still had root SSH access, but I was afraid to screw things up.

You see, I’m not a big Linux geek. I know I’m screwing up my tech-cred right off the bat, but at home I run Windows XP solely. I used to dual-boot Linux, but not anymore.

Anyway, over even more time, I had more issues with this particular host. When my VPS finally went down and it was taking them forever to get it back up, I decided to switch.

The Switch

So, I ditched the host I had and purchased a shiny new VPS from Linode. I was a little nervous at first; Linode VPS’ don’t use any fancy Plesk control panel–you get a blank distro of your choice, and then you install stuff. I would be responsible for all the content apps (Apache, PHP, MySQL), security (SSH, firewall), and… well, everything else. I wasn’t sure if I could handle it.

So, I sat down with my new VPS and started installing stuff. And, within the day, everything was set up, locked down, and working just great! I proceeded to set up my VirtualHosts in Apache and get all my sites back up and running. Things were looking great!

However, one of the things I had to do with the old host was switch my WoW blog from WordPress to Serendipity, due to memory usage on the host. I want to switch it back to WordPress.

The Problem

The problem is that this particular blog, thealtoholic.com, is already running in a VirtualHost. I obviously don’t want to work on the actual thealtoholic.com until I’m certain everything will transfer over smoothly. But, I don’t have another domain name to use for a VirtualHost entry in Apache. What to do? Well, here’s what I decided to do.

The Solution

First of all, decide on a random domain name you want to use. I used something along the lines of randomsitetotest.internal, just because I was feeling silly. I want this fake domain name to point to my IP address, 67.18.89.189.

Next, you need to point that fake domain name to your IP address. In Windows, start a text editor and open the file C:\WINDOWS\system32\drivers\etc\hosts and add the following line at the bottom:

67.18.89.189    randomsitetotest.internal

This tells windows to point your fake domain name to your IP address. Then it’s just a matter of setting up your VirtualHost entry in Apache’s conf file.

<VirtualHost *:80>
        ServerName randomsitetotest.internal
        DocumentRoot /var/www/vhosts/randomsitetotest.internal/httpdocs
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/vhosts/randomsitetotest.internal/httpdocs>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
...
</VirtualHost>

Now, browsing to randomsitetotest.internal in your browser should take you to your virtual host! Once you’re done, you can finalize your changes by copying your files from one directory to the other.

Thoughts

Did it work? Yep, like a charm! Was it the easiest or smartest way to do it? Probably not, but it’s what popped into my head so I thought I’d give it a try. Leave notes in the comments if you know of a better method!

, , , ,

No Comments