For Ubuntu 8.10, Apache 2.x, Firefox 3.0, Opera 9.6
I have a basketful of applications written in C/C++ that I would want to web-enable, i.e. make accessible from the web. All use MySQL via ODBC (in C/C++) and output to local OS GUIs. I will put the backend database stuff on an Apache server and do the GUI in a browser. The two will communicate via AJAX and JSON.
The backend cannot be recoded in PHP or PERL. It is too big. There is a fair amount of work needed to generate JSON data, so it would be impractical and take too long to upload to an external server, so I want to use the Apache server on my PC.
I have never used Apache with AJAX before and got into problems right away after issuing XMLHttpRequestObject.open("GET", url );
The test html file toajax.html is in /home/ken/projects/ajax directory and so is the executable cgi test program ajax.cgi written in C:
Code:
int main ( int argc , char * argv[] )
{
printf ("Content-Type: text/plain; charset=us-ascii\n\nAJAX - Hello\n" ) ;
return 0 ;
}
Content of /etc/apache2/httpd.conf:
Code:
ScriptAlias /cgi-bin/ /home/ken/projects/ajax
AddHandler cgi-script .cgi
<Directory "/home/ken/projects/ajax">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
</Directory>
1. Security error
Firefox Error console returns
When url="/cgi-bin/ajax.cgi" OR "file:///cgi-bin/ajax.cgi"
Security Error: Content at file:///home/ken/projects/ajax/toajax.html may not load data from file:///cgi-bin/ajax.cgi.
When url= "http:///cgi-bin/ajax.cgi"
Security Error: Content at file:///home/ken/projects/ajax/toajax.html may not load data from
http://cgi-bin/ajax.cgi.
I expected the ScriptAlias directive to expand /cgi-bin/ in the url to filepath:
file:///home/ken/projects/ajax/ajax.cgi
2. fetches executable content instead of executing it
When url="ajax.cgi"
The callback is executed, but the the data is the content of ajax.cgi
I expected the <directory> directive in /etc/apache2/httpd.conf to execute ajax.cgi.
So, not much joy so far.
What do I need to do to execute ajax.cgi on my local apache?