- Check the CGI Help Pages.
- Apply for a UND Engineering Linux Account.
- Use VPN (Virtual Private Network) to connect to the UND networks.
You may not need to do this if you are on campus.
- 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:
shell> mkdir ~/public_html
shell> mkdir ~/public_html/cgi-bin
where the symbol ~
is the user’s root in the Linux file system.
- Execute the command
chcon
.
Execute the following command at the server undcemcs02
.
Otherwise, your CGI scripts will not work.
shell> chcon -R -t httpd_sys_script_exec_t /home/“USER.ID”/public_html
Swap out “USER.ID” with your login name:
shell> chcon -R -t httpd_sys_script_exec_t /home/first.lastname/public_html
- 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:
shell> chmod 755 ~/../user.id
shell> chmod 755 ~/public_html/
shell> chmod 755 ~/public_html/*
shell> chmod 755 ~/public_html/cgi-bin/
shell> 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:
shell> chmod 755 ~/../user.id
shell> chmod 755 ~/public_html/
shell> 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:
shell> 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: