Write the first CGI program

1. First make sure that yourapache http server starts.



< /span>

The server is not up yet


Start the server



2. Write cgi executable file

#include int cgi_hello_world(){ std::cout<<"Content-type:text/html

"; std::cout< <"
"; std::cout<<"
"; std::cout<<" Hello World -First CGI Program
"; std:: cout<<"
"; std::cout<<"
"; std::cout<<"

Hello World! This is my first CGI program

"; std:: cout<<" "; std::cout<<" "; //std::cout<<" "; return 0;}int main (){ cgi_hello_world(); return 0;}

g++ 1.cpp -o cgi_hello_world -g


copy cgi_hello_world to the cgi-bin directory of the apache server



3. Access


< /span>

Browser input http://192.168.1.211:8080/cgi-bin/cgi_hello_world

Leave a Comment

Your email address will not be published.