Personal Web Pages

From CIS Support
Jump to: navigation, search

Every user account in the CIS department can have a personal web site associated with it. To activate this site, one must place a public_html directory in one's home directory to house the web site. The contents of that directory will then become available via http://www.cis.ksu.edu/~<username>.

Permissions

One common sticking point with personal web sites in the CIS department is the issue of file permissions. The proper file permissions are essential if others are to be able to successfully view your content.

In Linux the three primary permission categories are user, group, and everyone. Each of these categories then has read, write, and execute permissions. They are traditionally viewed as strings that look like rwxrwxr-- or something similar. Here are some examples:

  • rwxrwxr-- - User: read, write, execute; Group: read, write, execute; Everyone: read only
  • rw-r----- - User: read and write; Group: read only; Everyone: no access
  • r-xr-xrwx - User: read and execute; Group: read and execute; Everyone: read, write, execute
  • r-x-----x - User: read and execute; Group: no access; Everyone: execute

Importantly, Linux uses the execute permission to determine if a client can traverse a directory. Even if every file in a directory is full access for everyone, if the directory those files are in do not have the execute permission set for everyone, they will not be able to see it.

Therefore, it is very common to need to set the following permission on your home directory and public_html directory when first creating your personal site.

chmod 711 ~
chmod 755 ~/public_html
chmod 644 ~/public_html/index.html


These commands correspond to:

  • Set permissions of my home directory to rwx--x--x
  • Set permissions of my public_html directory to rwxr-xr-x
  • Set permissions of my index.html file in public_html to rw-r--r--

At this time you may wish to run the command man chmod to learn more about how to set file permissions.

Fixing permissions on all files in a directory

Sometimes when you upload new files to your site, the permissions may all be incorrect. The following commands will recursively look in the current directory and fix permissions for all subdirectories and files accordingly.

To fix all subdirectories

find ./ -type d -exec chmod 755 {} +

To fix all files

find ./ -type f -exec chmod 644 {} +

These are the equivalent of "find files (f) or directories (d) recursively, starting in the current directory (./) and run the chmod command on anything found that matches ({})". The + at the end tells the shell to combine commands as much as possible to save time and resources. Run ls -la before and after to make sure permissions are changed correctly.

Static Content

Static content includes images, html, and other content that is not executed on the server side. The everyone group will need to have read permission to any file that you wish to make available via your web site. All directories that contain static files will need to have the execute permission for the everyone group.

Dynamic Content

Dynamic content is content that is executed on the server and the output of that execution is sent to the client. All dynamic content for personal websites are executed as CGI scripts. Permissions are very important on executable scripts and it is essential that no other user but the owner may have write permission to the script and the directory that contains the script. An example acceptable permission scheme is:

chmod 755 public_html
chmod 644 public_html/index.php

Traditionally, cgi scripts that are not PHP (or other inline embedded language) are stored in a cgi-bin directory inside of your public_html directory. An example acceptable permission scheme for the cgi-bin is:

chmod 755 public_html/cgi-bin
chmod 755 public_html/cgi-bin/your-script.cgi

The header of your file should not use direct paths. Instead use the /usr/bin/env program as follows::

#!/usr/bin/env perl

Department Listing

Once you have created your personal website, you may link to it from anywhere. After your site is up, go to your user account on the main website, login, click "edit", and then "general info". Simply check the box that says "Show personal webpage", and then click "Save". Your name and link will automatically appear on "students" page on the main website.