Our first program uses C++ to calculate \(11+21\) and embed the obtained output into an html code. This will prove that our installation of the software and customizations of the server are working.
/var/www/html/test01 with the command
cd /var/www/html/test01
progTest01 for our source file.
nano progTest01.cpp
#include<iostream>
int main(){
std::cout<<"\n";
std::cout<<"<!DOCTYPE html>\n";
std::cout<<"<body> <h1> Hello CGI / C++ </h1> <p>Hi</p><p>Hi again!</p>";
int x;
int y;
x=11; y=21; int z; z=x+y;
std::cout<<"<p>The sum of the numbers "<<x<<" and "<<y<<" is "<<z;
std::cout<<" </p>\n";
std::cout<<"</body></html>\n";
return 0;
}
cgi. This is a way to do that
c++ progTest01.cpp -o myWebsite.cgi
https://yourdomain.com/test01/myWebsite.cgi