This is a tutorial to show students at SUNY Oswego how to set up a website on the CS servers. The only thing you will need in order to follow along is an account to get on the CS machines. If you do not already have an account, ask one of the professors to make one for you.
This tutorial assumes no prior experience with computer science or making websites. If you do have experience, and it seems like I am telling you things you already know, I apologize in advance. :)
A few notes about formatting:
Many of the CSA members hang out in Shineman 442 and 446. Bother them if you have any questions.
The CS department has a number of servers, which are named Altair, Moxie, Pi, Rho, Wolf, and Lambda. Among other things, these servers host the CS faculty and student websites.
In this example, my terminal's prompt is "angie@mylaptop>". Your prompt might look completely different. I use my CS username "agraci2" to connect to the CS servers with the ssh command, and specify the domain "cs.oswego.edu".
Try using the ssh command, but with your username instead of mine.
angie@mylaptop> ssh agraci2@cs.oswego.edu
Password:
You may receive a warning about using an unknown host key. If you're feeling trusting, you can simply type "yes" and press enter.
tcsh: using dumb terminal settings
.
If so, you must change your environment a little:altair - agraci2 - ~ > setenv TERM xterm
altair - agraci2 - ~ > reset
You should now have a terminal open, with a welcome message similar to the one below (except with your user name rather than mine).
Last login: Sun Jan 25 14:33:50 2015 from aolclient-68-17
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
altair - agraci2 - ~ >
You can interact with the server by typing in commands after the prompt (which in this case is "altair - agraci2 - ~ >").
In order for the CS servers to serve your website to the people visiting your page, you will need to make a space to store your website that:
On the CS servers, every user has a home directory. This directory's name will be the same as your username, and will be under the parent directory "home".
To make sure that you are in your home directory, you can use the pwd command, which prints the working directory.
altair - agraci2 - ~ > pwd
/home/agraci2
If you get something other than "/home/" followed by your user name, you can always change the directory to your home by using the cd command.
altair - agraci2 - ~ > cd /home/agraci2
Now if you try the pwd command again, it should show you that you are in your home directory.
In order to tell the CS servers that you want a file to be available over the web, that file must be stored in a directory called "public_html" in your home directory.
You can make a directory using the mkdir command.
altair - agraci2 - ~ > mkdir public_html
To see the results of the previous command, you can list the current directory's contents using the ls command.
This example shows the contents of my home directory when I use the ls command. You may have some different directories than me, but "public_html" should be in the list.
altair - agraci2 - ~ > ls
Desktop Downloads Example Public public_html Templates
Now that you have a place to put your website, you should make that directory available for the public to access. Since the "public_html" directory is in your home directory, you must make your home directory available to the public as well.
To accomplish this, we will use the change mode command, chmod to change some access permissions.
While in my home directory, I can use the chmod command to allow others to read and execute files without allowing them to write anything.
altair - agraci2 - ~ > chmod 755 .
This gives the current directory (my home directory) the permissions described above.
altair - agraci2 - ~ > chmod 755 public_html
And this gives my "public_html" directory the permissions described above.
WARNING: The above steps can make it so that everything in your home directory can be read by other people in Oswego CS! If you have homework or personal files that you don't want other people to be able to read, follow the step 2.3 to make a private directory.
You can make a space for your private files by using the mkdir command to create a directory, and the chmod command to make that directory readable only by you.
altair - agraci2 - ~ > mkdir MyPrivateFolder
altair - agraci2 - ~ > chmod 700 MyPrivateFolder
Now any files I put in "MyPrivateFolder" can only be read by me.
If you want to double-check the permissions for your files or directories, you can use the ls command with the "-l" flag to list the contents of a directory and display additional information about each item.
altair - agraci2 - ~ > ls -l
total 20
drwxr-xr-x+ 2 agraci2 sebs 4096 Dec 8 2013 Desktop
drwxr-xr-x+ 2 agraci2 sebs 4096 Oct 18 2013 Downloads
drwxr-xr-x+ 2 agraci2 sebs 4096 Oct 20 17:35 Example
drwx------+ 3 agraci2 sebs 4096 Feb 8 17:13 MyPrivateFolder
drwxr-xr-x+ 2 agraci2 sebs 4096 Aug 27 2013 Public
drwxr-xr-x+ 7 agraci2 sebs 4096 Jan 25 20:19 public_html
drwxr-xr-x+ 2 agraci2 sebs 4096 Aug 27 2013 Templates
The permissions are displayed using the notation in the leftmost column.
As you can see, everyone can go into all of my directories except for "MyPrivateFolder".
Now that you have created a space for your website, it's time to put something there!
Earlier, you learned how to change your directory by using the cd command, and giving an absolute path to your destination. You can employ this same technique again to get into your "public_html" directory.
altair - agraci2 - ~ > cd /home/agraci2/public_html
Another way to navigate is by using relative paths. This means that you specify where you want to go relative to where you currently are.
From inside my home directory, I can go to my "public_html" directory using the cd command and the directory name. Then I can use the pwd command to double-check where I am.
altair - agraci2 - ~ > cd public_html
altair - agraci2 - ~ > pwd
altair - agraci2 - ~ > /home/agraci2/public_html
I can also go back to the parent directory of where I currently am by using the special directory name "..". In this case, I would go back to my home directory.
altair - agraci2 - ~ > cd ..
altair - agraci2 - ~ > pwd
altair - agraci2 - ~ > /home/agraci2
First, what is HTML? Simply put, HTML or "HyperText Markup Language" is a language that allows you to describe a webpage. That description can then be understood by a browser (such as Firefox, Chrome, or Safari), and displayed to users.
From inside your "public_html" directory, open a new file called "hello.html" in the Emacs text editor.
altair - agraci2 - ~ > emacs -nw hello.html
Any text you enter now will be a part of the "hello.html" file. Try entering the text below exactly as it appears.
<!DOCTYPE HTML>
<html>
<head>
<title>Hello</title>
</head>
<body>
Hello, world!
</body>
</html>
Now you are ready to save your HTML file!
A message should appear at the bottom of your screen along the lines of:
Wrote /home/agraci2/public_html/hello.html
.
Once your "hello.html" file has been saved, you can exit Emacs.
You should be greeted once again with a command prompt.
Your website is now available on the web.
One good resource for learning HTML and other languages used to make websites is the w3schools. Once you make a webpage, you might want to validate it, to make sure your HTML code is well-formatted.