Web page

From Peyton Hall Documentation
(Redirected from Home page)
Jump to navigation Jump to search

Every account in Peyton Hall can have its own web site for others to see. This article will teach you a little about how to set it up, and what kinds of things you can do.


Getting started

To create your web site, create the directory ~/WWW/public: 'mkdir -p ~/WWW/public' will do the trick. Some places use the more standard ~/public_html, but since our web server was setup a long time ago to use this directory for pages, the tradition has carried over. Any files you place in this directory will be viewable at http://www.astro.princeton.edu/~<your username>/. If you want a page to display by default when someone uses that URL, name that page 'index.html'.


Access problems

If your page is not displaying, there's a few things to consider. Apache needs to be able to read the file itself, as it does not run as you but with its own user ID. This means that anyone needs to be able to access the directory and read the file, so having permissions set to lock out your home directory will also lock out Apache. Make sure that your home directory permissions are 755 (drwxr-xr-x) as are the subdirectories in question (~/WWW and ~/WWW/public). 'chmod 755 ~ ~/WWW ~/WWW/public' will do that for you.

Also, the files themselves have to be readable by all, so make sure their mode is 644 (-rw-r--r--). Again, 'chmod 644 index.html' is an example of how to do that. See chmod for more information on file and directory modes.


Password protection

You can have your page, or parts of it, password protected so that someone needs to type a password to see it. This might be useful if you have some collaborators you wish to give access to some data, but not have it show up in search engines or viewable by the general public. Start by creating a directory, with normal permissions. Inside that directory, you'll want to create two files, .htaccess and .htpasswd. .htaccess should look something like this:

AuthUserFile /u/user/WWW/public/your/directory/.htpasswd
AuthName "Whatever You Want To Call It"
AuthType Basic
require valid-user

Then your .htpasswd file. From a Linux workstation, run:

read -p "Username: " U ; P=`openssl passwd -apr1` ; echo "${U}:${P}"

This will create the data that you should put in the .htpasswd file you specified in .htaccess. You will be asked for the user name and password. Create the .htpasswd file with that data, or add it to the existing file if you're creating another user/password combination. Now when you mouse over to that page, you'll get the nice popup window that says "Please enter username and password for 'Whatever You Want To Call It'" (or whatever you typed in for 'AuthName' in .htaccess). Enter the username you gave in the read/OpenSSL command above, and then the password, and it should let you view whatever is in that directory.