Your ITP Stage Server Account [top]
The place where we will keep our finished work is the ITP stage server located at itp.nyu.edu. Each of you have an account which is located in "/home/[NetId]". For those who have not used this account, you will need to choose a password. To do this, go to:
Nancy Lewis was kind enough to set up a help page about the new ITP Stage server at:
http://itp.nyu.edu/help/pmwiki.php/Help/YourAccount
Once you have activated your account, you can now login to Stage and begin setting up your production environment.
Communicating with Stage [top]
Now that your account is active, we need a way to move files to it and to issue some basic commands. NYU has turned off telnet privileges, so the only safe bet is a secure shell or secure FTP client.
All PCs on the floor have:
To begin communicating with Stage, you can do the following:
ITP Stage Server Basics [top]
As I said before, each of you have an account which is located in "/home/[NetId]". Inside of this is a folder called "public_html". From a web perspective, if you create an HTML page called index.html and put it in public_html, this is the page that will be seen if you go to:
http://itp.nyu.edu/~[NetId]/
Thus, the actual filepath:
/home/[NetId]/public_html/
maps to the virtual filepath (i.e. the "web" filepath):
http://itp.nyu.edu/~[NetId]/
Here's what Nancy says about this on the Stage Help page:
The URL to your pages will be:
In order for your files to be Web accessible (viewable through a Web browser), you'll need to upload your files into your /public_html/ directory.
http://itp.nyu.edu/~netid/ will automatically display the index.htm or index.html file in your /public_html/ directory.
http://itp.nyu.edu/~netid/somdir/ will automatically display the index.htm or index.html file in your /public_html/somedir/ directory.
If you do not have an index.htm/index.html file, you will not be able to view anything, unless you go directly to a file by typing in the full path:
This is because directory browsing/indexing (list files in a directory) is turned off.
http://itp.nyu.edu/~netid/ (that's a tilde before the netid)
http://itp.nyu.edu/~netid/myfile.htm
http://itp.nyu.edu/~netid/somedir/thisfile.html
Creating a Home For Your Work [top]
It's always a good idea to keep your Stage dirs organized so you know where everything is. I created a 'dwd' directory inside of public_html to hold my work. There are two ways to create dirs on Stage:
Testing A Hello, World PHP Script [top]
To test your account setup on Stage, we will create a test PHP script locally on whatever computer we may be using, upload that script to the "dwd" directory that we just created on the Stage server. We will then access this file via our web browser to see if it executes properly. So, to begin, create a local file on your computer with a text editor and call it "hello.php" Inside of this file, cut and paste the following:
<?php
#########################################################
# hello.php - Our first PHP script
#########################################################
$scriptName = "hello.php";
$pageTitle = "Hello, World";
# Make sure we display errors to the browser
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
?>
<html>
<head>
<title><?=$pageTitle?></title>
<style type="text/css">
body {
font: 13px arial;
color: #000;
background-color: #fff;
padding: 10px;
margin: 0px;
}
</style>
</head>
<body>
<b><?=$pageTitle?></b>
</body>
</html>
Now, SFTP the "hello.php" file from your local computer to "/home/[NetId]/public_html/dwd/" on Stage.
IMPORTANT: When SFTPing PHP or HTML files to Stage, make sure that the transfer mode is set to ASCII and not binary or your scripts may not execute properly.
Verify that the privileges of the file "hello.php" on the Stage server are set to 644. If they are not, use your SFTP client to correct this, or SSH to Stage, change the directory to "/home/[NetId]/public_html/dwd/" and issue the following command
chmod 644 hello.php
Finally, go to the following URL to see if your script has executed:
http://itp.nyu.edu/~[NetId]/dwd/hello.php
and you should see the "Hello, World!" greeting in its big beautiful glory.
Common Problems [top]
If you don't get the desired results, check the list of common problems below:
404 File Not Found Error
This means that the URL, as you typed it, does not exist on the server. Remember that UNIX-based web servers like Stage are case-sensitive, so any capitalized letters will need to match the path and file of your script.
Blank Page
Scripts with syntax errors in them will render as blank pages. The only way to debug this on Stage is to login to Stage using a secure shell client (see the next section), navigate to the directory that contains the script, and then run it from the command line, like this:
php hello.php
where "hello.php" is the name of the script of interest. The PHP executable will then list the error along with the line number on which it occurs. You can then go back to this line number in your text editor to see what the problem might be.
You may also want to use the "more" command to show the contents of the script file, like this:
more hello.php
Make sure this file contains what it is supposed to, and was not changed either by the program you used to create it, or when you SFTPed it. This can happen if you saved your files in RTF format (the default for some text editors), for example, or if you SFTPed your file in binary mode instead of ASCII, or if you saved your script with the wrong line break type (see below under "Line Break Issues").
500 Internal Server Error
On some servers, a script with syntax errors will render as "Internal Server Error". In this case, simply follow the steps outlined under "Blank Page". The issue is the same.
Line Break Issues
Note that depending on your operating system and what editor you use, there may be an issue with how line breaks are inserted into your code. Windows uses CR and LF characters to terminate lines. UNIX uses an LF character only, and Macs use a CR character only. For your code to work correctly on Stage, which uses UNIX, there must be an LF character present at the end of a line if you need a line break. In some editors, such
as Dreamweaver, there is a setting for how line breaks are specified.
This can be remedied via Terminal by logging into your account via SSH (see the next section), navigating to the dir where the script lives and executing one of the following:
mac2unix hello.phpif you used a Mac-based machine to create your script
dos2unix hello.phpif you used a Windows-based machine to create your script
If you still have problems ...
Check the following things:
Debugging Using The Command Line Interface via SSH [top]
Sometimes the only way you can find out where an error is occurring is to run it from the command line. To SSH to your Stage account via Terminal, try the following (PC users - use your favorite SSH client to connect to stu.itp.nyu.edu using your net ID and password, and then follow along from the 4th bullet point). Remember to substitute your net ID for the text "netID" below:
ssh netID@stu.itp.nyu.edu
/home/netID
pwd
ls
cd public_html
cd dwd
ls
php test.php
more test.php
cd ..
cd [dir] - change location to directory [dir] pwd - print out the current directory (where am I?) ls - list the contents in the current directory more [file] - print the contents of [file] php [file] - run [file] through the PHP intepreter
Embedded CSS [top]
if you look closely at the "hello.php" example, you'll see that I've put in a little bit of visual formatting using Cascading Style Sheets (CSS). The following CSS provides some visual padding at the border of our page, showing black Arial text against a white background:
<style type="text/css">
body {
font: 13px arial;
color: #000;
background-color: #fff;
padding: 10px;
margin: 0px;
}
</style>
We'll learn more about CSS later in the semester, but just because we aren't CSS wizards yet doesn't mean we can't add a little class to our class examples (no pun intended).
Useful UNIX Commands: [top]
Directory Listing commands:
> ls
List the contents of the current directory.
> ls dirname
List contents of the directory dirname.
> ls -a
List all the files in a directory, including ones whose names begin with a period (.)
> ls -l
Long listing. List the contents of a directory, with the protection, owner, size, modification date, and name of the files.
> ll
Long listing. Synonym for ls -l.
> ls -la | more
Long listing of all files in current directory, and the output is piped to the command "more", which pauses when the screen is full.
Directory manipulation commands:
> mkdir dirname
Make directory. Creates a new, empty directory named dirname.
> rmdir dirname
Remove directory. A directory must be empty before it can be removed.
Directory movement commands:
> pwd
Print working directory. Prints the name of the current directory.
> cd dirname
Change directory. Changes the current directory to dirname.
> cd ..
Change to parent directory. Moves up one level in the directory hierarchy.
> cd
cd with no arguments will change the current directory to the home directory
File manipulation commands:
> more file1
Prints file1 to the screen, but pauses when the screen is full.
> cp file1 file2
Copies file1 to file2.
> mv file1 file2
Moves file1 to file2. If the arguments are in same directory, this command just renames file1 to file2. If file2 is a directory, file1 is moved to that directory.
> rm file1
Removes file1.
> chmod 755 file1 [or] chmod 644 file1
Change the read/write/execute properties of a file. For PHP files, and also static documents like HTML, CSS, and image files, this command should be chmod 644 file1 which is the default when a document is created. For a Perl or CGI script, it should be chmod 755 file1 in order for the script to be executed by a web user.
Miscellaneous commands:
> exit
Exits an xterm window. If you are logged in remotely, this command will log you out of the system.
Eclipse SFTP File Sync [top] Note: The actual text/steps may vary, depending upon your version of Eclipse, but all the basics are there. To equate a local directory with a pre-existing remote one:
Related Resources [top]
HTML Reference