$wget ftp://ftp.gnu.org/gnu/cgicc/cgicc-X.X.X.tar.gz
$tar xzf cgicc-X.X.X.tar.gz
$cd cgicc-X.X.X/
$./configure --prefix=/usr
$make
$make install
2. For Ubuntu users, the default cgi-bin folder is located under /usr/lib/cgi-bin.
Add this location to apache httpd.conf, and restart the server:
$sudo gedit /etc/apache2/httpd.conf
type
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
<Directory "/usr/lib/cgi-bin">
Options All
</Directory>
in httpd.conf file, save and exit gedit. Restart apache with
$sudo /etc/init.d/apache2 restart
Optional:
You may test if cgi-bin folder is running under apache by testing it with a basic .php echo file.
3. Create a new .cc file wherever you like, let's say on Desktop, and type:
#include <iostream>
using namespace std;
int main ()
{
cout << "Content-type:text/html\r\n\r\n";
cout << "<html>\n";
cout << "<head>\n";
cout << "<title>Hello World - SECOND CGI Program</title>\n";
cout << "</head>\n";
cout << "<body>\n";
cout << "<h2>Hello World! This is my second CGI program</h2>\n";
cout << "</body>\n";
cout << "</html>\n";
return 0;
}
open Terminal, navigate to Desktop and compile demo.cc file using
$g++ demo.cc -o demo.cgi
Your build name is demo.cgi, and you may test it now with
$./demo.cgi
4. Move demo.cgi to cgi-bin folder with:
sudo cp demo2.cgi /usr/lib/cgi-bin
5. Go to http://localhost/cgi-bin/demo2.cgi to see your webpage.