centos7 nginx支持cgi

来源:互联网 发布:python django教程 编辑:程序博客网 时间:2024/06/05 20:37

centos7 nginx 支持cgi

由于本人的代码使用git管理,代码浏览器使用的cgit。webserver为nginx,而cgit为c语言实现的cgi程序。为了在nginx下依然可以用cgit,所以有了这篇文章。

1、fcgiwrap的安装和配置

# install fcgi-develyum install fcgi-devel# install fcgiwrap# 由于centos源没有fcgiwrap,所以需要自行下载源码安装git clone https://github.com/gnosek/fcgiwrap.gitcd ./fcgirwapautoreconf -i./configuremakemake install# 配置fcgiwrap based systemdcp systemd/* /usr/lib/sytemd/system/# 根据自己需求修改fcgiwrap.server中一下内容,ExecStart=/usr/sbin/fcgiwrap -s tcp:127.0.0.1:8082                                                                                   User=nginxGroup=nginx# 启动fcgiwrapsystemctl start fcgiwrap

2、nginx的配置

# 在/etc/nginx/conf.d/内增加自己的针对cgi程序的配置,配置如下server {     listen                80;     server_name           git.yourdoman.cn;     root                  /var/www/cgi-bin/cgit-data;     try_files             $uri @cgit;     location / {         fastcgi_param       SCRIPT_FILENAME /var/www/cgi-bin/cgit;         #fastcgi_index       cgit;         fastcgi_param       PATH_INFO       $uri;         fastcgi_param       QUERY_STRING    $args;         fastcgi_param       HTTP_HOST       $server_name;         fastcgi_pass        127.0.0.1:8082;                                                                                                  include             fastcgi_params;    }}
原创粉丝点击