Server Lab

Goals and Big Ideas

This lab is just to give you a head start on Phase 3 of the webapp project. The goal is to set up your designated directory on the web server so that you can easily pull files from your Bitbucket repository and have them show up live on the web.

Your web application for Project 2 is going to live on a server called thacker that's hidden away somewhere in the CMC. On that computer, there's a directory set up for you at the following path:

/Accounts/courses/cs257/jadrian/web/CARL_USER

If you're on campus, then accessing the following URL through the web

http://thacker.mathcs.carleton.edu/cs257/CARL_USER/foo

will ask the web server on Thacker to look for a file called foo in the directory named above.

However, we don't have direct physical access to Thacker. Instead, if we want to work with this machine, we need to log into it remotely, and we'll only be able to work through the command-line interface.

Editing files remotely, sending them back and forth manually, etc. is a real pain. When you're developing a server-based application, the best way to manage your files is through your version-control system.

With a little preliminary setup (the steps in this lab), you'll have an easy two-step process to make changes to stuff on the server: working on your own computer, you'll push some changes to your Bitbucket repository; then you'll log into Thacker and pull those changes.

1. Connect to Thacker

SSH into thacker.mathcs.carleton.edu.

ssh thacker.mathcs.carleton.edu

Your terminal should now be showing you a remote shell on the Thacker server. (“SSH” stands for “Secure SHell” — a “shell” is the interface you use to interact with the computer, often a command-line interface.) You can double check that your login succeeded by telling yourself the hostname:

echo $HOSTNAME

That tells you the name of the computer that your current shell is on. If you get a different computer name than Thacker, then your SSH log-in didn't succeed.

If you're working from a computer on which your username is different from your Carleton username, then you need to specify it when you SSH:

ssh CARL_USER@thacker.mathcs.carleton.edu

2. Clone Your Repository on Thacker

Do all these steps on Thacker, still connected by SSH. Make sure that you're in your home directory on Thacker when you begin these steps.

  1. Make a link to your webapp directory — the directory where you can put stuff so that it's visible in the browser.

    ln -s /Accounts/courses/cs257/jadrian/web/CARL_USER 257_web

    This is just for convenience; this way, if you want to get to the webapp directory in the future, you can just move into the directory called 257_web.

  2. Move into that directory.
    cd 257_web
  3. Now your current working directory should be the webapp directory. This directory should currently be empty.

    Clone your webapp repository directly into the current directory. (Note the dot at the end of this command — it indicates the current directory!)

    git clone https://BITBUCKET_USER@bitbucket.org/MAIN_BITBUCKET_USER/cs257_webapp.git .

    If git complains about the configuration of pushes, you may need to edit ~/.gitconfig and comment out the push configuration.

    If you accidentally clone incorrectly, then delete the directory that was created by the clone process and try it again. Remember the current directory must be completely empty in order for a clone into the directory to succeed!

3. Push a File

Back on your current system, if you don't already have your cs257_webapp repository checked out here, clone it as normal.

Now make a dummy file called webapp.html in your Git repository, and put some basic HTML in there:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Webapp test!</title>
</head>
<body>
    <p>Anybody there?</p>
</body>
</html>

Check your new file into source control, and push it.

4. Pull It to Thacker

Back on Thacker, pull from source control. You should see your webapp.html file directly in the ~/257_web directory where you cloned your repository previously.

Open http://thacker.mathcs.carleton.edu/cs257/CARL_USER/webapp.html in the browser and confirm that you see your expected page.