Nginx/fcgiwrap

Материал из ALT Linux Wiki
Перейти к: навигация, поиск

Настройка nginx для запуска CGI скриптов на примере collectd[править]

Требуется поставить пакеты:

nginx
fcgiwrap
spawn-fcgi
collectd-cgi

конфигурационные файлы[править]

/etc/sysconfig/spawn-fcgi:

## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/usr/bin/spawn-fcgi"

## ABSOLUTE path to the PHP binary
FCGIPROGRAM="/usr/sbin/fcgiwrap"

## ip to listen
## *must* be commented out for use with unix domain socket
#FCGILISTEN="127.0.0.1"

## bind to tcp-port on localhost
## *must* be commented out for use with unix domain socket
#FCGIPORT="1027"

## unix domain socket permissions
#SOCKETUSER=
SOCKETGROUP=_nginx
SOCKETMODE=0770

# allowed environment variables sperated by spaces
ALLOWED_ENV="PATH"

## if this script is run as root switch to the following user
USERID=_spawn_fcgi
GROUPID=_spawn_fcgi

/etc/nginx/sites-enabled.d/collectd.conf:

server {
       listen   80;
       access_log  /var/log/nginx/access.log;

       location / {
               root   /var/www/html/collection3/bin;
               autoindex on;
               index  index.cgi;
               auth_basic "Admin Zone";
               auth_basic_user_file /var/www/html/collection3/etc/.htpasswd;
                       
       }
        
       location /share {
               alias /var/www/html/collection3/share/;
       }

       location ~ \.cgi$ {
               root    /var/www/html/collection3/bin;
               rewrite ^/cgi-bin/(.*)\.cgi /$1.cgi break;

               include /etc/nginx/fastcgi_params;

               fastcgi_pass   unix:/var/run/spawn-fcgi/spw-cgi.sock;
               fastcgi_param  SCRIPT_FILENAME  /var/www/html/collection3/bin/$fastcgi_script_name;
       }

       location ~ /\.ht {
               deny all;
       }

}

NB: на основе этой статьи создан субпакет collectd-cgi-nginx.

Ссылки[править]