- Check the CGI Help Pages.
- Apply for a UND Engineering Linux Account.
- Log in to the Linux Server
undcemcs02.und.edu
.
- Create a Sub-Directory “~/public_html/cgi-bin” under the Root Directory.
Create the directory by using the command mkdir:
undcemcs02> mkdir ~/public_html
undcemcs02> mkdir ~/public_html/cgi-bin
where the symbol ~
is the user’s root in the Unix file system.
- Execute the Command
chcon
.
Execute the following command at the server undcemcs02
.
Otherwise, your CGI scripts will not work.
undcemcs02> chcon -R -t httpd_user_content_t \
/home/”USER.ID”/public_html
Swap out “USER.ID” with your login name:
undcemcs02> chcon -R -t httpd_user_content_t \
/home/first.lastname/public_html
(or replace the above two commands by the following two commands:
undcemcs02> chcon -R -t httpd_user_content_t /home/”USER.ID”/public_html
undcemcs02> chcon -R -t httpd_user_content_t /home/first.lastname/public_html
where the backslash symbol ‘\’ is used to continue the current command to the next line.)
- Create a CGI Script.
Create/edit a CGI script in the cgi-bin
directory.
The cgi-bin
directories are set up so that they do not serve plain HTML pages; they just execute a given CGI script.
An example of a CGI Perl script is ~/public_html/cgi-bin/demo/cgi/1.pl
.
Check the CGI Programming 101 for how to write CGI scripts.
†Note that a compiler, activated in a CGI script, can not successfully generate an object file if the source program results a warning message.
- Open the CGI Script.
This step is NOT needed if the default permission of files is open or the web server is the script’s owner:
Otherwise, open the CGI scripts to let the browser access them by using the command chmod :
undcemcs02> chmod 755 ~/../user.id
undcemcs02> chmod 755 ~/public_html/
undcemcs02> chmod 755 ~/public_html/*
undcemcs02> chmod 755 ~/public_html/cgi-bin/
undcemcs02> chmod 755 ~/public_html/cgi-bin/*
where user.id
is your Linux account identifier.
†Note that the above commands may not be complete.
You have to open all the files and directories in the public_html
directory.
If CGI writes to your directory, such as ~user.id/public_html/out/
, then you need to open that directory.
For the example of that directory:
undcemcs02> chmod 755 ~/../user.id
undcemcs02> chmod 755 ~/public_html/
undcemcs02> chmod 777 ~/public_html/out/
†Note that if you write the file to the directory where the CGI script is, this will cause “Internal Server Error,” that is, try NOT to do the following:
undcemcs02> chmod 777 ~/public_html/cgi-bin/
- View the Execution Results of the CGI Scripts.
You can then check the execution results of your CGI scripts on the browser.
For the example of the CGI script ~/public_html/cgi-bin/demo/cgi/1.pl
, submit one of the following buttons: