主页

安装nginx

sudo apt-get install nginx

安装cgi库

sudo apt-get install fcgiwrap

vi /etc/nginx/sites-enabled/default 
 
//在第一个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;
                # 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

sudo service nginx restart

创建目录

mkdir /var/www/cgi-bin

vi /var/www/cgi-bin/hello.sh

#!/bin/bash
echo "Content-Type:text/html"
echo "" 
echo "hello world!"

给权限

chmod +x /var/www/cgi-bin/hello.sh

版权属于:WANYL
作品采用:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
0

目录

来自 《nginx配置cgi-bin》
评论

WANYL

博主很懒,啥都没有
125 文章数
0 评论量
11 分类数
126 页面数
已在风雨中度过 3年357天21小时3分