Home CPSC 225

Creating a Website

As part of your account on the CPSC server, you have access to simple web hosting. The way that this works is that everything you put in a special directory called "public_html" will be accessible over the web. This page contains instructions for setting that up.


 

The public_html Directory

This directory contains everything that you wish to be publicly viewable over the web. Make the directory with the mkdir command:

ifinlay@cpsc:~$ mkdir public_html

Now we can place files inside of this directory. For instance, we can place a file called "test.txt" inside of public_html:

ifinlay@cpsc:~$ echo "Hello this is a test!" > test.txt
ifinlay@cpsc:~$ mv test.txt public_html/

Then I can navigate to "https://cpsc.umw.edu/~ifinlay/test.txt" to view the file over the web:


Viewing a file over the web

Of course when you do this, you will replace "ifinlay" with your own user name.


 

HTML Files

You can use your public_html directory simply as a way to access the files you have stored on the CPSC server from other computers. This might be more convenient for you then transferring things with scp or FileZilla. You could also use it to host files like a résumé.

However, the server can also be used to create a personal web site by putting HTML files in your public_html, along with CSS and Javascript files. The server also supports PHP sites. If you have a file in the public_html directory called "index.html" or "index.php" it will be displayed if you navigate to just "https://cpsc.umw.edu/~yourusername/". This allows you to designate one page as the home page essentially.


 

Permissions

In order for your files to show up on the web, the public_html directory needs to have both read and execute permission for group and other. If it does not, the web server will not be able to access it. This is how the permissions should look:

drwxr-xr-x 2 youruser students 4096 May 30 09:59 public_html

If the permissions aren't right, you can fix it with chmod:

ifinlay@cpsc:~$ chmod 755 public_html

For the files inside of public_html to be viewable, they need to have the right permissions as well. In general, you can give files the 644 permission and directories the 755 permission to make sure they are readable. This should be the default, but is good to double-check if something isn't showing up for you.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.