Creating a Website at CSE
Each user account is entitled to a website, which is hosted out of the home directory of the account.You may also be interested in using CGI Scripts and general information about World Wide Web things at CSE.
Executive summary
Your entire website, i.e. all files and scripts comprising it, has to be contained within your ~/public_html directory. Symbolic links to files outside public_html will not be followed. It is customary to put CGI scripts in a cgi-bin subdirectory. File permissions have to be set so as to be accessible by the webserver (see next section). You can access your website by either of these URLs:- http://www.cse.unsw.edu.au/~username/
- http://username.web.cse.unsw.edu.au/
http://www.cse.unsw.edu.au/~username/cgi-bin/coolscript.pl
If you're on a CSE-linux computer you can shorten http://www.cse.unsw.edu.au/~username/ to http://www/~username/ (this doesn't work for the username.web form of the URL).File Permissions
The webserver runs as a user (w3serv, for the interested) and therefore is treated as just-another-user by the filesystem when it tries to access your public_html. This means you have to set world file access permissions:- world-execute on all directories including your homedir, a step often forgotten
- world-read on all files, unless they are scripts
- world-execute on all scripts
As always, never set world-write on any file or directory.Detail
You can set up a website with public access by putting your home page in the file index.html, or one of the alternatives listed below, in a directory called public_html in your home directory. public_html is created for users on their first login but needs to be manually created for other accounts. Your home directory and the public_html directory will both need to be world-executable (which allows anybody to access the directory), because to the filesystem a browser is coming from the outside world - even if it's you running the browser looking at your own web page on the CSE system. You can do this using chmod. The HTML files within public_html that you want people to be able to access need to be world-readable. Any scripts you want people to be able to run need to be world-executable and, if you like, can also be world-readable.How to setup a website in one minute:
- cd this sets your current working directory to your homedir
- mkdir public_html if necessary
- chmod o+x public_html
- chmod o+x .
- vi public_html/index.html (or use your favorite editor)
- chmod o+r public_html/index.html
When asked to access a CSE website, i.e. the CSE webserver receives a request for either http://www.cse.unsw.edu.au/~username or http://username.web.cse.unsw.edu.au, it looks within ~username/public_html for a file called one of the following:
- index.html
- index.htm
- index.shtml
- index.cgi
- index.php
This file is the homepage. If it does not exist or isn't world-readable the webserver will return an error if somebody tries to access the base website. However, URLs accessing a specific file within the website will still work. For example, with the following directory:
%ls -l ~fblo123/public_html
total 100
-rw-r----- 1 fblo123 fblo123 278767 May 2 21:21 index.html
-rw-r--r-- 1 fblo123 fblo123 278767 May 2 21:21 aboutme.html
the URL http://fblo123.web.cse.unsw.edu.au/ will return an error, but http://fblo123.web.cse.unsw.edu.au/aboutme.html will work.
index.html needs to be written in HTML as will, most likely, the majority of your files. By convention files in your website, like other files, are suffixed to indicate the content: indeed, HTML files need to be suffixed with .html in order to be rendered by most browsers. Scripts don't necessarily need a suffix as long as they start with a line invoking the relevant interpreter, but it will make life easier for you if you label them .pl or .php appropriately. Each HTML file is a webpage. When beginning to build your website, you will probably hyperlink most of your webpages to index.html; later as you become more ambitious you may want a definite structure. There are many places to learn about HTML, but a couple of good sites for beginners are:
http://www.htmlcodetutorial.com/ http://http://www.htmldog.com/guides/htmlbeginner/ which also includes a Beginner's Guide to CSS.
If you just want information on the HTML tags (elements) there are lots of websites for that also, but W3.org is about as authoritative as you can get:
http://www.w3.org/TR/html4/index/elements.html
HTML is easy to write. Bad HTML is even easier. Cast an eye over http://webpagesthatsuck.com/ occasionally and learn some basic design principles.
Related topics
There are lots of other questions relating to your own website at CSE!- World Wide Web (start here)
- CGI Scripts
- Restricting Web Access - How to restrict access to web pages
- Personal Domain - Can I get my own domain?
- htaccess - usage and configuration of .htaccess directives
- Robots.txt - How can I have my own robots.txt file?