Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

How to use boa?

I wanna add cgi scripts to my web server (boa), I do things like this:

1.select boa in the filesystem config.

2.make a dir with the name cgi-bin in /home/httpd

3.config boa.conf: add a line : ScriptAlias: /home/httpd/cgi-bin/ /cgi-bin/

4.add a *.exe file(compiled by IDE,sorce is c language) to /home/httpd/cgi-bin/

5.build filesystem & upload

6.ifconfig ......

7 in IE, type the IP, I can see the default index page,but when I type http://ip/cgi-bin/*,that (http://ip/cgi-bin/*,that) show the exe file in text mode, that is unknown words.

ps:the cgi script is run correctly by Apache in both Fedora Core 3 & Windows XP

* is my cig file name

why?

Thanks a lot! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    What is the name of your .exe file, and how does it appear in the filesystem on the board?

    For example, if I put a file, test.exe, in the /target/home/httpd/cgi-bin/ folder in my filesystem project, then rebuild and upload this project, it will appear as
    /home/httpd/cgi-bin/test
    when I log in and view it through nios2-terminal. As well, its permissions will be -rwx-xr-x

    Does your executable differ from this in any way?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    the mode has been changed to executable,and it can be seen in SDK shell correctly(html text).

    Another question: other web server, like Apache, it will make a dir with the name cgi-bin automatically, but to boa, we must make it by ourselves. Can it work ?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi, in order for boa to properly run an executable, the extension of the file must be changed to .cgi.

    Additionally, for the executable to be run correctly, it needs to output to standard out (before outputting anything else) a "cgi header". Since a CGI program can return a myriad of document types, a CGI program must place a short header (ASCII text) on its output so that the client will know how to interpret the information it generates.

    Most commonly, CGI programs generate HTML, so the header that needs to be output is:

    Content-type: text/html\n\n

    Note that this header MUST include the two new lines at the end.

    Since the executable you are trying to run has been compiled from C source, you need to put this line in your program:

    printf("Content-type: text/html\n\n");