HowTo: Public HTML

Filed under: Technical References

Posted: March 7, 2009

Anyone with an account on the CS Linux Servers, is given free space to create their own website, by making use of thier “public HTML” folder.

Instructions

* If you haven’t already done so, create a folder in your home directory called “public_html” . Newer accounts should have this folder automatically created for them.
* Check and make sure that your home directory and public_html folder have the correct permissions set, or else the contents of the folder will not be accessible to the outside world.

      aschenck@london ~ $ cd
      aschenck@london ~ $ mkdir public_html
      aschenck@london ~ $ ls -ld . public_html
      drwx—— 2 aschenck ugrad 4096 Sep 24 13:45 .
      drwxr-xr-x 2 aschenck ugrad 4096 Sep 24 13:45 public_html

* What does this all mean, anyway? Well, when the user executed mkdir public_html, they created a directory called “public_html”. The mkdir command is creates directories and ls to views the contents. (Node the -d argument tells ls to list the directory itself, instead of the contents of that directory, and the -l tells it to give more detail than just the name).
* Look at the first part of the output of ls -ld public_html. The “drwxr-xr-x” means that the directory public_html is readable, writeable, and executable by the owner (in this case, aschenck), readable, not writable, and executable by the group (in this case, ugrad), and readable, not writable, and executable by everyone else. If the last three characters show “–x”, then you’re all set. Otherwise, execute these command:

      aschenck@london ~ $ chmod 0701 ~
      aschenck@london ~ $ chmod 0701 ~/public_html

* This sets execute permissions to other users (for a directory, that means they can change to it (required by the webserver)), and then removes read permissions from other users (so people can’t get directory listings). Note that 0701 is the octal version of rwx—–x.
* To upload material, use “HowTo: SCP” or sftp.
* If you want a directory to appear instead of “access forbidden”, you need to give other users read permission (chmod o+r).
* If you want to make a page appear instead of a directory when you go to http://www.cs.uri.edu/~yourusername, add a file in your public_html directory called “index.html” or “index.php”. If you want to create dynamic pages, the CS servers have PHP and Python installed.