This is an old revision of the document!
Deploy A Basic CGI Application
General Information
Deploying a basic CGI application via a bash script.
Lab Setup
The following virtual machines will be used:
- server1.example.com (192.168.1.150) → Perform all connectivity tests from here
- server2.example.com (192.168.1.151) → Install Apache Web Server here
Previous Sections Completed
-
- Except leave listening on port 80/tcp
Create the Bash Script
Create a basic script
vim /var/www/cgi-bin/mytime.sh #!/bin/bash echo -e "Content-type: text\n" echo "This is the current time on the system: $(date)"
- Note: There MUST be a newline after the “Content-type: text” line in order for the cgi script to work correctly. (Either in the form above with 'echo -e' and the '\n' or another empty echo command)
Make script executable
chmod +x /var/www/cgi-bin/mytime.sh
Find SELinux CGI boolean to ensure its on
getsebool -a | grep httpd_enable_cgi
If OFF, set it to ON
setsebool -P httpd_enable_cgi 1
Test CGI deployed script
elinks http://bluesite.example.com/cgi-bin/mytime.sh