Creating a website

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 can also use CGI Scripts in your site.

Where to put the files

All the files and scripts for your site go in your ~/public_html directory.

For security, the webserver cannot access any files outside of this directory.

The default page should be named index.html (or index.php for PHP powered sites).

The URL of your site

You can access your website at one of two URLS:


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


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 or, 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 will return an error, but 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:// 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 is about as authoritative as you can get: HTML is easy to write. Bad HTML is even easier. Cast an eye over occasionally and learn some basic design principles.

Specifying Charset for web pages (optional)

If you notice your website failed to display the expected contents due to character encoding you can change server-side directives in Apache to specify the character encoding sent by the server.

To do so, you will need to modify the .htaccess file in your website directory.
more details about .htaccess usage, please see Restricting web access(taggi)

Open .htaccess file in text-editor, use the following syntax to specify the character encoding for the selected file extension AddCharset encoding .file_extension For instance, to following example will server all files with the extension .html as UTF-8 AddCharset UTF-8 .html You can use <File> tag to apply different character encoding to your nominated pages. The following example will server UTF-8 for example.html page only. <Files "example.html"> AddCharset UTF-8 .html </Files> More details can be found on W3C website: Setting charset information in .htaccess(W3C)

Related topics

There are lots of other questions relating to your own website at CSE!
Last edited by mgao 27/09/2017

Tags for this page:

html, web, url