Loading ...
Sorry, an error occurred while loading the content.

25143Re: Can't run cgi files with nginx and php-fcgi

Expand Messages
  • mick_nslu2
    Mar 24, 2013
    • 0 Attachment
      The solution is to use:

      http://wiki.nginx.org/Fcgiwrap

      or better and to do it properly:

      http://projects.unbit.it/uwsgi/

      none of which are available in optware. So I used thttpd which can do cgi.


      --- In nslu2-linux@yahoogroups.com, "mick_nslu2" <mick_nslu2@...> wrote:
      >
      > Hi All,
      >
      > I hope someone can point me in the right direction with this problem. I have installed and configured nginx, php, php-fcgi and spawn-fcgi on an unslung slug. Initially I configured /opt/etc/nginx/nginx.conf as I show below to be able to use nginx and php-fcgi to display php files:
      > ================================
      > server {
      > listen 80;
      > server_name localhost;
      > root /home/httpd/mrtg;
      > location / {
      > index index.html index.htm;
      > }
      >
      > #Pass all .php files onto a php-fpm/php-fcgi server.
      >
      > location ~ \.php$ {
      >
      > try_files $uri $uri/ =404;
      >
      > fastcgi_split_path_info ^(.+\.php)(/.+)$;
      > include fastcgi_params;
      > fastcgi_index index.php;
      > fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      > #fastcgi_intercept_errors on;
      > fastcgi_param QUERY_STRING $query_string;
      > fastcgi_param REQUEST_METHOD $request_method;
      > fastcgi_param CONTENT_TYPE $content_type;
      > fastcgi_param CONTENT_LENGTH $content_length;
      > #fastcgi_pass 127.0.0.1:1026;
      > fastcgi_pass unix:/tmp/php-fcgi.sock;
      > }
      > ================================
      >
      > To spawn fastcgi I have a script under /opt/etc/init.d/ to start php-fcgi and bind it to a unix socket:
      >
      > FCGISOCKET="/tmp/php-fcgi.sock"
      >
      > This has worked fine, but now I want to also be able to process cgi-bin/routers2.cgi for graphing some mrtg data and I am not sure if I need to install anything else and/or how to configure nginx. This is what I have tried adding to nginx.conf, after some google searching and head scratching:
      > ================================
      > location ~ ^/cgi-bin/.*\.cgi$ {
      > gzip off;
      > fastcgi_pass unix:/tmp/php-fcgi.sock;
      > #fastcgi_pass unix:/var/run/nginx/cgiwrap-dispatch.sock;
      > fastcgi_index index.cgi;
      > fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      > fastcgi_param QUERY_STRING $query_string;
      > fastcgi_param REQUEST_METHOD $request_method;
      > fastcgi_param CONTENT_TYPE $content_type;
      > fastcgi_param CONTENT_LENGTH $content_length;
      > #fastcgi_param GATEWAY_INTERFACE CGI/1.1;
      > #fastcgi_param SERVER_SOFTWARE nginx;
      > #fastcgi_param SCRIPT_NAME $fastcgi_script_name;
      > #fastcgi_param REQUEST_URI $request_uri;
      > #fastcgi_param DOCUMENT_URI $document_uri;
      > #fastcgi_param DOCUMENT_ROOT $document_root;
      > #fastcgi_param SERVER_PROTOCOL $server_protocol;
      > #fastcgi_param REMOTE_ADDR $remote_addr;
      > #fastcgi_param REMOTE_PORT $remote_port;
      > #fastcgi_param SERVER_ADDR $server_addr;
      > #fastcgi_param SERVER_PORT $server_port;
      > #fastcgi_param SERVER_NAME $server_name;
      > }
      > ================================
      >
      > However, instead of the browser showing the result of the *.cgi script, it just loads up the content of the file. Any idea what I need to do to enable nginx to process cgi files - *without* adding a separate web server to do this, but using some fastcgi method instead?
      > --
      > Regards,
      > Mick
      >
    • Show all 2 messages in this topic