国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

在ubuntu下為nginx配置支持cgi腳本的方案

2024-08-30 12:25:46
字體:
來源:轉載
供稿:網友

在nginx下支持cgi腳本于支持node類似的,只要在nginx直接做個轉發,轉發到對應的cgi套接字就好。

使用Fcgiwrap

Fcgiqwrap是另外一個CGI封裝庫,跟Simple CGI類似。

安裝fcgiwrap

apt-get install fcgiwrap

安裝以后fcgiwrap默認已經啟動,對應的套接字是 /var/run/fcgiwrap.socket 。如果沒有啟動,使用 /etc/init.d/fcgiwrap 手動啟動。

配置nginx的vhost文件

在要支持cgi腳本的路徑下,添加對應的server配置。比如所有的cgi都在cgi-bin路徑下:

server {[...]  location /cgi-bin/ {   # Disable gzip (it makes scripts feel slower since they have to complete   # before getting gzipped)   gzip off;   # Set the root to /usr/lib (inside this location this means that we are   # giving access to the files under /usr/lib/cgi-bin)   root /var/www/www.example.com;   # Fastcgi socket   fastcgi_pass unix:/var/run/fcgiwrap.socket;   # Fastcgi parameters, include the standard ones   include /etc/nginx/fastcgi_params;   # Adjust non standard parameters (SCRIPT_FILENAME)   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  }[...]}

重新加載nginx:

nginx -s reload

測試

在cgi-bin下創建hello-world.cgi

#!/usr/bin/perl -w   # Tell perl to send a html header.   # So your browser gets the output   # rather then <stdout>(command line   # on the server.)print "Content-type: text/html/n/n";   # print your basic html tags.   # and the content of them.print "<html><head><title>Hello World!! </title></head>/n";print "<body><h1>Hello world</h1></body></html>/n";

設置執行權限

chmod 755 /var/www/www.example.com/cgi-bin/hello_world.cgi

在瀏覽器打開對應腳本,即可看到已經配置成功! http://www.example.com/cgi-bin/hello_world.cgi

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 中方县| 三亚市| 邻水| 丹寨县| 皮山县| 那坡县| 高阳县| 卓尼县| 定襄县| 陇南市| 仪陇县| 翁牛特旗| 黔西县| 鲁甸县| 庐江县| 梧州市| 盈江县| 石嘴山市| 沙河市| 天门市| 新绛县| 新和县| 额尔古纳市| 大悟县| 大名县| 胶南市| 青海省| 昭觉县| 阿图什市| 襄汾县| 清涧县| 桂平市| 神农架林区| 霍城县| 长武县| 峡江县| 永年县| 德州市| 南川市| 吴堡县| 玉田县|