How to get your first PHP script running at Stanford

From Web Services Wiki

Revision as of 08:11, 25 September 2008 by Reyner (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

Problem

You have a SUNetID, and you want to get a PHP script running in your web space.

Solution

Activate CGI account

  • Personal CGI service
  • Group, Dept, Class CGI service

Become familiar with AFS

Your CGI account may take some time to be created, sometimes up to one hour or longer. In the meantime, it would be helpful to get a jump start on learning about AFS, the file system used at Stanford. AFS for beginners is a useful resource in understanding what AFS is, how to access and navigate it, and how to perform more advanced operations such as setting permissions.

Install client software

Stanford provides several utilities for accessing your files in AFS. Visit Essential Stanford Software (ESS) to view a list of all available software. You may use the OpenAFS client or a SFTP client to connect.

Connect to AFS

  • Connect to an AFS server in your client software using your SUNetID and password.
  • Verify that the cgi-bin directory exists in the root directory. Create a test PHP script containing the following, and place it in cgi-bin:
<?php
echo "Hello world!";
?>
  • Try to access the script by visiting www.stanford.edu/~your_sunetid/cgi-bin/script_name.php. If you see "Hello world!" then your CGI account is configured correctly.

Troubleshooting

Page not found

If you are receiving a "page not found" error, the URL may have been entered incorrectly. Verify that you are accessing your page correctly.

Personal account:
http://www.stanford.edu/~sunetid/cgi-bin/your-script.php
 
Group account:
http://www.stanford.edu/group/group_name/cgi-bin/your-script.php
 
Department account:
http://www.stanford.edu/dept/dept_name/cgi-bin/your-script.php

Browser attempts to download the script

If the browser is attempting to download the script, this means that the server is failing to parse the file. Verify the following:

  • The script is located in the cgi-bin directory, not under WWW
  • Your CGI account has been activated
    • Visit Request CGI Form to activate your CGI account. Remember that it may take some time for your account to become active.
  • The permissions are correct
    • Visit Request CGI Form even if your account has already been activated to reset permissions on the directory, then try to access the script again.
    • Ensure that the script has user-level read permissions
      • chmod 400 script_name.php

For more information

Personal tools