解壓包
tar zxvf nginx-1.8.1.tar.gz
tar zxvf pcre-8.35.tar.gz
tar zxvf zlib-1.2.8.tar.gz
tar zxvf openssl-1.0.1i.tar.gz
添加用戶
groupadd -r nginx
useradd -r -g nginx nginx
編譯安裝
cd /opt/software/nginx-1.8.1
./configure \
--prefix=/opt/nginx \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_realip_module \
--pid-path=/var/run/nginx.pid \
--with-pcre=/opt/software/pcre-8.35 \
--with-zlib=/opt/software/zlib-1.2.8 \
--with-openssl=/opt/software/openssl-1.0.1i
make
make install && echo OK
啟動nginx
正確性檢查
#每次修改nginx組態檔后都要進行檢查
/opt/nginx/sbin/nginx -t
啟動nginx
/opt/nginx/sbin/nginx
reload nginx
/opt/nginx/sbin/nginx -s reload
一鍵安裝腳本
將以上步驟整合到一個腳本中來編譯安裝nginx
安裝spawn-fcgi:
l 獲取spawn-fcgi編譯安裝包,在http://redmine.lighttpd.net/projects/spawn-fcgi/wiki上可以獲取當前最新的版本。
l 解壓縮spawn-fcgi-x.x.x.tar.gz包。
l 進入解壓縮目錄,執行./configure。
l make & make install
l 獲取fcgi編譯安裝包,在http://www.fastcgi.com/drupal/node/5上可以獲取當前最新的版本。
l 解壓縮fcgi-x.x.x.tar.gz包。
l 進入解壓縮目錄,執行./configure。
l make & make install
在/include/fcgio.h檔案中加上 #include <cstdio>,然后再編譯安裝就通過了
如果提示找不到動態庫,請在LD_LIBRARY_PATH或/etc/ld.so.conf中添加fcgi的安裝路徑,如/usr/local/lib,并執行ldconfig更新一下。
#include "fcgi_stdio.h"
#include <stdlib.h>
int main(void)
{
int count = 0;
while (FCGI_Accept() >= 0)
printf("Content-type: text/html\r\n"
"\r\n"
"<title>FastCGI Hello!</title>"
"<h1>FastCGI Hello!</h1>"
"Request number %d running on host <i>%s</i>\n",
++count, getenv("SERVER_NAME"));
return 0;
}
編譯g++ main.cpp -o demo –lfcgi,并將demo部署到/opt/nginx-1.7.7/cgi-bin/目錄
通過spawn-fcgi啟動c/c++撰寫好的fastcgi程式:/opt/nginx-1.7.7/sbin/spawn-fcgi -a 127.0.0.1 -p 8081 -f /opt/nginx-1.7.7/cgi-bin/demo
3.1.3. nginx fastcgi配置
關于nginx的幾個組態檔決議,可以參閱《Nginx安裝與使用》http://www.cnblogs.com/skynet/p/4146083.html,在上篇的nginx.conf基礎上增加下面的fastcgi配置。
這樣nginx收到http://localhost/demo.cgi請求時,會匹配到location = /demo.cgi塊,將請求傳到后端的fastcgi應用程式處理。如下如所示:(注意其中number為80,是因為我請求了80次)
uj5u.com熱心網友回復:
過來搬磚,圍觀教程轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/108923.html
標籤:應用程序開發區
上一篇:求助,關于ffmpeg調av_interleaved_write_frame記憶體一直在掉
下一篇:linux命令制作腳本
