How to get your first PHP script running at Stanford

From Web Services Wiki

Jump to: navigation, search



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


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:
echo "Hello world!";
  • Try to access the script by visiting If you see "Hello world!" then your CGI account is configured correctly.


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:
Group account:
Department account:

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