国产探花免费观看_亚洲丰满少妇自慰呻吟_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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 建水县| 陇西县| 平遥县| 仁化县| 银川市| 铜山县| 秦皇岛市| 双峰县| 钟山县| 松阳县| 沙湾县| 泸溪县| 定西市| 宿州市| 寻乌县| 库尔勒市| 车致| 集贤县| 廉江市| 中山市| 新密市| 禹州市| 夹江县| 安顺市| 慈利县| 沭阳县| 潜山县| 兴安盟| 镇康县| 黔西县| 漳浦县| 务川| 固始县| 河津市| 清流县| 荔波县| 鹤庆县| 东源县| 淮安市| 精河县| 仙游县|