nginx 0.6.3 安裝與配置(linux,nginx,php-cgi)

nginx 0.6.3 安裝與配置(linux,nginx,php-cgi)

     nginx 的 rewrite 網站頁面地址重寫功能需要正則表達式模塊 PCRE,另外頁面壓縮傳輸需要 zlib。     
     nginx 配置時只需引用下載後解壓的 PCRE 和 ZLIB 源文件即可: ./configure –prefix=/usr/local/nginx &nginx 的 rewrite 網站頁面地址重寫功能需要正則表達式模塊 PCRE,另外頁面壓縮傳輸需要 zlib。
      nginx 配置時只需引用下載後解壓的 PCRE 和 ZLIB 源文件即可:
./configure –prefix=/usr/local/nginx –with-pcre=/backup/pcre-7.7 –with-zlib=/backup/zlib-1.2.3
      在網上看到的另一種方法是:
Nginx的編譯參數如下:
[root@localhost]#./configure –prefix=/usr/local/server/nginx –with-openssl=/usr/include \
–with-pcre=/usr/include/pcre/ –with-http_stub_status_module –without-http_memcached_module \
–without-http_fastcgi_module –without-http_rewrite_module –without-http_map_module \
–without-http_geo_module –without-http_autoindex_module在這裏,需要說明一下,由於Nginx的配置文件中我想用到正則,所以需要pcre模塊的支持。我已經安裝了pcre及pcre-devel的rpm包,但是 Ngxin 並不能正確找到 .h/.so/.a/.la 文件,因此我稍微變通了一下:
[root@localhost]#mkdir /usr/include/pcre/.libs/
[root@localhost]#cp /usr/lib/libpcre.a /usr/include/pcre/.libs/libpcre.a
[root@localhost]#cp /usr/lib/libpcre.a /usr/include/pcre/.libs/libpcre.la然後,修改objs/Makefile大概在908行的位置上,註釋掉以下內容:
./configure –disable-shared接下來,就可以正常執行make及make install了。
      看樣子是比較麻煩的。另外一個問題是 md5 sha1 這兩個東西 nginx 真的需要麼???在網上查了一篇文章作參考吧:
(選擇 –with-md5 或 –with-sha1 中的一個, 但不能都選; 在 debian 和 ubuntu 上, 它們應該都指向 /usr/lib)
(注: 根據 October 2006 message 的消息,md5 在一個現在不再使用的 http 緩存模塊中用到,而 sha1 用在一個未完成的 mysql 庫模塊,所以它們當前都不是必須的)
      其實想想也是,php 網站開發中的加密功能 php 都提供了,而 nginx 本身也不使用此功能。所以在配置的時候不用加入加密的選項了。
----------------------------------------
nginx 0.6.3 配置
這裏要借用一下 lighttpd 的 spawn-fcgi 文件,將其下載編譯安裝後拷貝到 /usr/bin 目錄下面備用:
php-fastcgi 文件配置:
#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/local/php/bin/php-cgi
注意用戶是 nobody, -f 後面是 php 提供的 cgi 解析程序路徑
fcgi.init 文件配置:
#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case “$1″ in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php
RETVAL=$?
;;
restart)
killall -9 php
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo “Usage: php-fastcgi {start|stop|restart}”
exit 1
;;
esac
exit $RETVAL
nginx 啓動文件 nginx.sh 配置:
#!/bin/sh
/backup/fcgi.init start
/usr/local/nginx/sbin/nginx
配置後:
The page you are looking for is temporarily unavailable.
Please try again later.
這是 php-fastcgi 裏面的 /usr/bin/spawn-fcgi 沒有正常啓動,將用戶 root 改爲 nobody,再啓動一次,正常了。
這次顯示:
No input file specified.
解決方案:
要麼:

fastcgi_param SCRIPT_FILENAME /ngweb/$fastcgi_script_name; # nginx.conf
fastcgi_param SCRIPT_NAME $fastcgi_script_name; # fastcgi_params

要麼:

fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; # nginx.conf
fastcgi_param SCRIPT_NAME /ngweb/$fastcgi_script_name; # fastcgi_params

/ngweb 是網站目錄,是要解析的 PHP 文件所在。
(責任編輯:admin)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章