ubuntu通过nginx部署fastcgi程序
ubuntu安装nginx
// 更新包
sudo apt-get update
// 下载安装nginx
sudo apt-get install nginx
卸载nginx
sudo apt-get --purge remove nginx
nginx的操作命令如下:
service nginx start service nginx stop service nginx restart
配置nginx支持fastcgi
开发fastcgi程序并将编译成功的fastcgi程序复制到工作目录(随意)
安装spawn-fcgi
sudo apt-get install spawn-fcgi
安装完成之后, spawn-fcgi的目录为 /usr/bin/spawn-fcgi
启动spawn-fcgi
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9002 -f /tmp/fcgi1
更改Nginx配置
sudo vim /etc/nginx/sites-available/default
添加以下内容
#location ~ .cgi$ {
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME fcgi$fastcgi_script_name;
include fastcgi_params;
}
重启Nginx
sudo service nginx restart
测试
在浏览器输入以下网址
http://127.0.0.1