圆月山庄资源网 Design By www.vgjia.com

在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

标签:
nginx,cgi,配置,nginx,php,cgi,配置,ubuntu,nginx启动脚本

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。