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

首頁 > 網站 > Nginx > 正文

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

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

在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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 谢通门县| 邹城市| 沙河市| 安龙县| 仙桃市| 永泰县| 衡南县| 贡觉县| 宝应县| 竹山县| 南木林县| 怀柔区| 乌兰察布市| 招远市| 周宁县| 镇平县| 翁源县| 黄冈市| 儋州市| 罗定市| 藁城市| 高青县| 连山| 双峰县| 勃利县| 兰溪市| 漳平市| 崇仁县| 全州县| 利辛县| 泰和县| 绥江县| 泰兴市| 禄丰县| 荆州市| 汝城县| 抚顺市| 贵溪市| 荥阳市| 石楼县| 炎陵县|