1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CGI on nginx server

Discussion in 'Server Configuration and Hosting' started by Andy.N, Sep 22, 2011.

  1. Andy.N

    Andy.N Well-Known Member

    My server is Ubuntu 11.04 running nginx latest version and I want to serve latex using mathtex.cgi script.
    I follow the mathtex installation here http://www.forkosh.com/mathtex.html and have verified that it works on the unix server.
    Now, according to the instruction, I just have to move the mathtex.cgi script to the /cgi-bin/ folder, chmod and it should work.

    I mkdir the folder, move the cgi file there and chmod 755.

    However, when I go directly to the cgi script using www.domain.com/cgi-bin/mathtex.cgi? instead of it showing the latex input/output, the browser just download the cgi file to my computer.

    Any nginx expert can help letting me know if I have to do anything on the nginx.conf file?

    Do I need to install fcgiwrap to server cgi or something?
  2. Slavik

    Slavik XenForo Moderator Staff Member

    Sounds like you havent configured nginx to tell it where the cgi bin interpreter is?
  3. Andy.N

    Andy.N Well-Known Member

    Glad someone helps me ;)
    Which nginx config file should I take a look at?

    or /etc/nginx/sites-enabled/domain.com
    I can send you a PC if you can spend a few minutes. Thanks a lot.
  4. Slavik

    Slavik XenForo Moderator Staff Member

    Im not familiar with nginx, but I would assume in the

  5. Luke F

    Luke F Well-Known Member

  6. SneakyDave

    SneakyDave Well-Known Member

    I think normally nginx.conf includes the /etc/nginx/sites-enabled/domain.com files. If it's supposed to be a global configuration, I'd put it in nginx.conf.
  7. Andy.N

    Andy.N Well-Known Member

    I tried http://wiki.nginx.org/Fcgiwrap
    • Install it using apt-get install
    • then do this
      cp /usr/share/doc/fcgiwrap/examples/nginx.conf /etc/nginx/fcgiwrap.conf
    • then add
      # fast cgi support
           include /etc/nginx/fcgiwrap.conf;
      to the /etc/nginx/nginx.conf file. I don't know if I put it in the wrong file or location in the file but when I restart nginx, this is the error.
      Starting nginx: nginx: [emerg] "location" directive is not allowed here in /etc/nginx/fcgiwrap.conf:3
    • Do I miss some other steps? I did start the fcgiwrap and chmod +x that script.
  8. SneakyDave

    SneakyDave Well-Known Member

    I think it doesn't like the "location" directive you may have in your nginx.conf, or it doesn't like where you put the include....

    I think that means that your Location directive isn't within an http{} setting block, is there not already an http{} statement in the file?
  9. Andy.N

    Andy.N Well-Known Member

    Here is the header part of the config file
    server {
      listen          80;
      server_name    quantnet.com;
      rewrite ^      http://www.domain.com$request_uri permanent;
      client_max_body_size 20M;
            #Fcgiwrap setting to serve cgi for latex
            # fast cgi support
          include /etc/nginx/fcgiwrap.conf;
    server {
                listen          80;
                server_name www.domain.com;
                            root  /home/andy/public_html/domain.com;
                            index  index.php;
  10. Andy.N

    Andy.N Well-Known Member

  11. Deebs

    Deebs Well-Known Member

    CGI is now working on Andy's site.
  12. Slavik

    Slavik XenForo Moderator Staff Member

    The fix?

Share This Page