Run C++ program through CGI

You can run your c++ code through CGI. But you must configure Apache2 with CGI and you must have install cgicc compiler to compile c++ code. Follow below steps to run c++ code through CGI.

1.To configure Apache2 with CGI follow previous post.

2.Create your c++ program file  using vi editer  under /usr/lib/cgi-bin.

$ sudo vi

for example:

c++ through CGI

3. After completion ,Compile your c++ code using cgicc compiler, If cgicc is not installed then install it using following steps:

  • Download cgicc from :
  • Extract your cgicc file.
  • Now goto directory where your extracted cgicc file is locate. for example: /home/manpreet/Downloads/cgicc-3.2.16
  • Run $ ./configure
  • Run $ make
  • Run $ sudo make install
  • Done (cgicc is installed now)

4. compile c++ code under /usr/lib/cgi-bin directory:

$ sudo g++ -o /usr/lib/cgi-bin/firstCGI

5.Change permissions of file

$ chmod 755

6. Run your c++ file on browser, type following on address bar



7. Done


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s