Nginx/fcgiwrap: различия между версиями
(Новая страница: «Настройка nginx для запуска CGI скриптов на примере collectd. Требуется поставить пакеты: nginx fcgiwrap...») |
м (+link) |
||
(не показано 6 промежуточных версий 2 участников) | |||
Строка 1: | Строка 1: | ||
Настройка nginx для запуска CGI скриптов на примере collectd | = Настройка nginx для запуска CGI скриптов на примере collectd = | ||
Требуется поставить пакеты: | Требуется поставить пакеты: | ||
nginx | nginx | ||
fcgiwrap | fcgiwrap | ||
spawn-fcgi | 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: на основе этой статьи создан субпакет {{pkg|collectd-cgi-nginx}}. | |||
== Ссылки == | |||
* http://lists.altlinux.org/pipermail/devel/2005-July/034994.html | |||
* [[Nginx/php5-fpm]] | |||
[[Категория:Web]] | [[Категория:Web]] |
Текущая версия от 15:24, 24 апреля 2012
Настройка 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.