Creating Web Site with Apache Server on Linux



  1. Department of Computer Science Web server's configuration you should know about to create your own web site.
    1. UNIX Convention

      Since the web server is running on Linux, you must follow UNIX conventions, such as:

      •  Linux is case sensitive, hence the web server is also case sensitive.

      • ~ (tilde) means home directory and / (forward slash) means root directory. However, when you use / with the web server, it means the web server's root, not the root of the whole system.
    2. Your Public Home Directory & your Default file

      • The web server can see only public_html* directory and its subdirectories in your home directory. So you should create public_html directory and place all Web documents in there. Make sure that the directories, including your home directory, have access permission (drwx--x--x) and the files have a read permission by world (-rwxr--r--).

        * This change was made recently. So if you already have your web site on cs servers, you have a WWW directory instead. You need to change this directory name to "public_html". Or you can just create a symbolic link called "public_html".

              To change the directory name to "public_html", issue the following command in your home directory:

        mv WWW public_html

              To create a symbolic link:

        ln -s WWW public_html

      • The file name of your default home page (accessed with "http://hostname.hood.edu/~your_login_name/) is index.html, index.shtml, index.htm, or index.php.
    3. CGI program files

      A CGI program file can reside in any directories under public_html, but it must have .cgi extension (or suffix). Make sure if your CGI program is executable by you (-rwx------).
    4. SSI (Server Side Includes)

      To use SSI functionality, a file must be saved with .shtml extension (or suffix).
    5. Security Issues

      If you placed your files under your public_html directory, your files are accessible to anyone in the world. So please do so carefully, particulaly executables. These are some suggestions.

      1. Make sure that all your directory permissions are set to (drwx--x--x) so that web server will not list directory contents, but users can see your web pages.

      2. If you do not intend your excutables to be used by others, change executable file permissions to (-rw-------). This way the files cannot be executed until you change the permissions back to executable.


  2. A quickest way to create web docuemnt (html format) from already existing one (such as doc format) is to save a docuemnt as html format.  If you are going to create html document from scratch, you might want to use a web composer/editor. When your html document is ready, place it in your public_html directory on the server.