Creating a Website on Chalmers’ Servers

Yesterday I helped a friend move a website over to the student web space provided by Chalmers University. I’m posting this up while it’s still fresh in my mind in the hope that it helps others looking to do the same.

Chalmers students each get 500MB to 1GB of space on the university network and 10MB for database use. You can use the space for storing files but also for hosting your own website. This guide is for anyone who’d like to use it to create a website or simply make files accessible through the web. It also covers setting up a MySQL database and connecting to it through a PHP script.

What you will need

Your URL at Chalmers

CID being the Chalmers ID assigned to you. From now on wherever I write ‘CID’, you should replace it with your real CID.

Step 1: Connect to the server

This guide uses FileZilla, an application which allows you to transfer files from your own computer to a remote server simply by dragging them over.

  1. Open FileZilla
  2. Select File > Site Manager…
  3. Click ‘New Site’
  4. Give it a name (e.g. ‘Chalmers’)
  5. On the right hand side enter the following details
    Servertype: SFTP - SSH File Transfer Protocol
    Logontype: Normal
    User: Your CID
    Password: Your CID password
  6. Click ‘Connect’

Step 2: Create the ‘www’ folder

Once you’re connected your working directory should be:
Files in this directory are not accessible over the web — you probably don’t want everything in your space accessible to the outside world anyway. To start making files available over the web, we have to create a ‘www’ folder in this directory.

  1. In FileZilla, right click on your CID and choose ‘Create directory’
  2. Type www to replace the selected text and click ‘OK’
  3. You should now see the www folder appear in the list

Anything you place in the www folder from now on will be accessible from the web.

Step 3: Upload a simple web page

  1. Save the HTML below to a file called index.html.
    <!DOCTYPE html>
    		<meta charset="utf-8" />
    		<title>Stu Dent's Home Page</title>
    		<h1>Stu Dent's Home Page</h1>
    		<p>Welcome! I'm a student at Chalmers 
    		training to be a good, obedient 
    		employee. I'm very happy.</p>
  2. In FileZilla, locate your newly created file and drag it into the www folder we created in the previous step.
  3. Now access in your browser, replacing CID with your real CID.

If everything worked out well, you should be seeing a page titled Stu Dent’s Home Page. If you’re happy working with HTML, CSS or even JavaScript, this guide ends here. You can upload whatever you like in your www folder and it will be accessible through the URL.

If you’d like to work with PHP and MySQL, follow the steps below.

Step 4: Add PHP

In this step we’re going to upload another file. It’s based on the HTML above but includes a little PHP to show the current date and time.

  1. Save the code below to a file called test.php.
    <!DOCTYPE html>
    		<meta charset="utf-8" />
    		<title>Stu Dent's Home Page + Date and Time</title>
    		<h1>Stu Dent's Home Page + Date and Time</h1>
    		<p>Welcome! I'm a student at Chalmers 
    		training to be a good, obedient 
    		employee. I'm very happy.</p>
    		<p>It is <?php echo date('l jS F H:i:s'); ?> 
    		inside this computer here in Gothenburg.</p>
  2. In FileZilla, locate test.php and drag it into the www folder.
  3. Now access in your browser.

If everything worked out well again, you should see a page titled Stu Dent’s Home Page + Date and Time.

If you see a message saying Internal error, the most likely reason is incorrect directory and file permissions. To fix the permissions first right click on the ‘www’ directory and choose ‘File Attributes…’. In the field labeled ‘Numeric value’ enter 755 and click ‘OK’. Now do the same for test.php but in the ‘Numeric value’ field enter 644.

Step 5: Enable MySQL

Before connecting to MySQL you need to create a database for your account. To do this you’ll need your CID/net username and password. The username is usually just your CID with ‘/net’ added to the end. So if your CID is ‘johns’ the username you use here is ‘johns/net’. You can read more about the difference on the Chalmers accounts page.

  1. Access
  2. When prompted, enter your CID/net username and your CID/net password.
  3. Under the MySQL heading, click ‘Skapa konto’ (create account)
  4. Make a note of the details: username, password, database name and server address

If you ever forget your password, you can login again and click the ‘byt lösenord’ button to get a new password.

Unfortunately I don’t think Chalmers offer GUI access to MySQL. So to administer your database you’ll have to either install a MySQL GUI app, or do it through the command line. I won’t explain how to do either of these here but you can follow the links in the further reading section below to find out more. And if you’re installing a popular PHP application, e.g. WordPress, it will take care of table creation for you — all you do is supply it with the details you noted down in this step.

Step 6: Create simple PHP + MySQL app

In this step we’ll connect to MySQL through PHP. The application is a very simple counter. Each time the page is accessed the MySQL database is updated to increase the counter value. The new value is then fetched and displayed to the user. It is made up of 3 PHP files:

  • connect_to_db.php5 contains the code to connect to the database we created in the previous step
  • create_table.php5 contains code to create the database table we’ll use to store the counter value
  • counter.php5 contains the code to update the counter value and display it to the user
  1. Save the code below to a file called connect_to_db.php5 and replace CID with your real CID and password with the database password you noted down in the previous step.
    // show all errors
    ini_set('display_errors', 1); 
    try {
    	// DB config
    	$username = 'CID'; // your CID
    	$dbname = 'CID';   // your CID
    	$pw = 'password';  // DB password
    	$hostname = '';
    	// try connecting
    	$pdo = new PDO(
    } catch (PDOException $e) {
    	// deal with errors
    	echo "Failed to get DB handle: ".$e->getMessage();
    } ?>
  2. Save the code below to a file called create_table.php5.
    // include PHP file which connects to the database
    require_once 'connect_to_db.php5';
    // create table
    $pdo->exec("CREATE TABLE counter(visitors int)");
    // insert initial value (0)
    $pdo->exec("INSERT INTO counter VALUES(0)");
    echo 'Done!'; 
  3. Save the code below to a file called counter.php5.
    // include PHP file which connects to the database
    require_once 'connect_to_db.php5';
    // update counter
    $pdo->exec("UPDATE counter SET visitors = visitors + 1");
    // get new value
    $row = $pdo->query("SELECT visitors FROM counter")->fetch();
    // show visitor count
    echo 'You are visitor '.$row['visitors'];
  4. Upload all 3 files to the www folder
  5. Access to create the table
  6. Now access to see the visitor count.
  7. Refresh the page and you should see the number increase — each time you access the page a new number is stored in the database.

Note: If you get the internal error message again, make sure you update the file permissions to 644 as described above. Also, by giving these new files .php5 extensions we force the server to use a newer version of PHP (PHP 5) to process the files.

Further reading

This entry was posted in General. Bookmark the permalink. Both comments and trackbacks are currently closed.


  1. Farshid says:

    Thanks for sharing your knowledge about this.

  2. g. says:

    K1 This is exactly what I need right now… Cheers! I’ll let you know if I manage to do it 😀

  3. g. says:

    I managed perfectly to get wordpress to work, and now I broke it… Guess I shouldn’t have done the 755-644 everywhere :'( Anyway, brilliant info there!

  4. Keyvan says:

    That’s great to hear it g. I haven’t tried setting up WordPress on a Chalmers account so it’s good to know it works. So you only had a problem when you changed all permissions?

  5. g. says:

    Yeah it’s very strange, it seemed at first it was resetting the permissions, but the wordpress ceased to work at all after 5 minutes. Not sure what happened there…

  6. Keyvan says:

    If it’s still not working, let me know what the error message is — I might try installing it just to test.

    Update: WordPress does work as long as you don’t enable permalinks — doing so will create a .htaccess which for some reason the server does not like. If you do enable by mistake, delete the .htaccess file in the WordPress root directory and change permalink settings to default.

  7. g. says:

    I found today that phpMyAdmin has errors connecting, but using Heidi SQL is a breeze, so I’d recommend that for backup duties. Thanks for the alternatives!

  8. Keyvan says:

    Thanks g. Good to know.

  9. I had no idea we could have a web page on,
    Thanks a lot for the info.