CGI/PHP on the Homepage Server

Can I run CGI/PHP scripts on the Homepage Server

Yes, you can run CGI/PHP scripts on the Homepage server if you have an active Unix userid.
Follow the steps below to set up the necessary support for scripts.

PHP scripts can be run from anywhere within your public_html directory.

CGI scripts (perl, bash, python, etc) can be run by following the procedure here:

  1. Create a cgi-bin directory within your public_html directory (for instructions on setting up your public_html directory, visit https://home.cc.umanitoba.ca/setup.html).
  2. Put your CGI/PHP script into the cgi-bin directory.
  3. Set the proper access permissions on the script and the directory by typing this command from within the public_html directory:
    • makepublic cgi-bin

Your script can be accessed by using the following URL format:
https://home.cc.umanitoba.ca/~userid/cgi-bin/scriptname

Every file in the cgi-bin directory must be set to be executable. This can be done by doing a chmod 755 on each file you create.

Please note:

You may wish to use a test script to ensure that everything is working properly.

Examples

The following python script, when entered into a file called hello_world.py and placed into the cgi-bin directory, will display "Hello World!" on a web page:

#!/usr/bin/python3
print("Content-Type: text/html\n")
print("<html>\n<head><title>Hello World</title></head>\n<body>")
print("<h1>Hello World!</h1>")
print("</body></html>")

The following perl script, when entered into a file called hello_world.pl and placed into the cgi-bin directory, will display "Hello World!" on a web page:

#!/usr/bin/perl
use CGI;
print "Content-Type: text/html\n\n";
print "<html>\n<head>\n<title>Hello World</title>\n</head>\n";
print "<body><center><h1>HELLO WORLD!</h1></center>\n";

print "<p>Hello World!</p>\n";
print "<p><em>Hello World!</em></p>\n";
print "<p><strong>Hello World!</strong></p>\n";

print "</body></html>\n";

The following PHP script, when entered into a file called php_test.php and placed into your public_html directory, will display "PHP rocks!" on a web page:

<html> <head> <title>PHP ROCKS!</title> </head> <body> <?php print "PHP rocks!"; ?> </body> </html>