CGI on nginx server

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?
 
Sounds like you havent configured nginx to tell it where the cgi bin interpreter is?
 
Sounds like you havent configured nginx to tell it where the cgi bin interpreter is?
Glad someone helps me ;)
Which nginx config file should I take a look at?

/etc/nginx/nginx.conf
or /etc/nginx/sites-enabled/domain.com
I can send you a PC if you can spend a few minutes. Thanks a lot.
 
Glad someone helps me ;)
Which nginx config file should I take a look at?

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

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

/etc/nginx/nginx.conf
 
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.
 
http://wiki.nginx.org/SimpleCGI or http://wiki.nginx.org/Fcgiwrap would be needed, not sure which one I set you up with before
I tried http://wiki.nginx.org/Fcgiwrap
  • Install it using apt-get install
  • then do this
    Code:
    cp /usr/share/doc/fcgiwrap/examples/nginx.conf /etc/nginx/fcgiwrap.conf
  • then add
    Code:
    # 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.
 
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?
 
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?
Here is the header part of the config file
Code:
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;
 
Top Bottom