本人使用的是Ubuntu系統
1、安裝nginx伺服器
http://nginx.org/download/nginx-1.9.2.tar.gz tar -zvxf nginx-1.9.2.tar.gz cd nginx ./configure make && make install
預設安裝路徑:/usr/local/nginx
nginx簡單設定:/usr/local/nginx/conf/nginx. /usr/local/nginx/sbin/nginx
關閉nginx:kill `ps aux|grep nginx|sed -n '1p'| awk '{print $2}'`2、安裝spawn-fcgi#user nobody; worker_processes 4; error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 90; #gzip on; server { listen 192.168.88.134:8080; //修改成自己的ip地址跟端口 server_name 192.168.88.134; #charset koi8-r; access_log logs/host.access.log main; location / { root html; index index.html index.htm index.php; #autoindex on; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9999; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } location ~ \.cgi$ { root html; fastcgi_pass 127.0.0.1:7000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } }3、安裝fast-cgi
apt-get install apawn-fcgirrregi複製的編譯到nginx目錄
cp./src/spawn-fc /nginx/sbin /cp/usr/
local/ .0 / usr/lib每個人安裝的目錄未必一致,請自行搜尋按安裝的目錄進行拷貝修改 wget http://www.fastcgi.com/dist/fcgi.tar.gz
tar -xvzf <span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">fcgi.tar.gz</span>
編譯:
此时不能编译安装
cd fcgi-2.4.1/include
打开fcgio.h 添加#include <stdio.h>
./configure
make && make install</stdio.h>
將test.cgi 拷貝到/usr/local/nginx/html/ 下
啟動spqwn-fcgi程序
#include <fcgi_stdio.h>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
while(FCGI_Accept() >=0)
{
FCGI_printf( "Status: 200 OK\r\n" );
FCGI_printf( "Content-Type: text/html\r\n\r\n" );
FCGI_printf( "Hello world in C\n" );
}
return 0;
}
</iostream></fcgi_stdio.h>
在nginx.conf 添加g++ -o test.cgi test.cpp -L /usr/local/lib/ -lfcgi
打開瀏覽器輸入:http://192.168.88.134:8080/test.cgi
文章參考:http://wiki.ubuntu.org.cn/Nginx
http://blog.chinaunix.net/uid-30030431-id-4669581.html //terry831010.blog.163.com/blog/static/6916117120126185428827/
載。 以上就介紹了nginx伺服器下編寫cgi程序,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

本文討論了PHP數據對象(PDO),這是PHP中數據庫訪問的擴展名。它通過準備好的語句及其對MySQLI的好處,包括數據庫抽象和更好的錯誤處理,強調了PDO在增強安全性方面的作用。

memcache和memcached是通過減少數據庫負載加快Web應用程序的PHP緩存系統。可以在仔細的密鑰管理的項目之間共享一個實例。

本文討論了JavaScript和PHP如何通過HTTP請求間接相互作用,因為它們的環境不同。它涵蓋了將數據從JavaScript發送到PHP的方法

文章討論了PHP從1995年的“個人主頁工具”到1998年的“ PHP:超文本預處理器”的演變,這反映了其超越個人網站的擴展使用。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3漢化版
中文版,非常好用

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中