2010年10月8日 星期五

另一好用的 Web server: nginx

下載 nginx web server
http://nginx.org/en/download.html
設定檔: nginx.conf 放在 nginx/conf
docroot 一般設定在 nginx/html
讓 php-cgi 可支援, 修改 nginx.conf,加入以下內容:

location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

如果要支援 drupal,修改 nginx.conf,加入以下內容:


location /drupal {
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.+)$ /drupal/index.php?q=$1 last;
}
}

如果要支援 wordpress , 修改 nginx.conf
location /wordpress {
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.+)$ /wordpress/index.php?q=$1 last;
}
}
如果要使用 sqlite 資料庫, 則到 wordpress 官網下載 pdo_sqlite plugin, 並將此plugin 模組放入 wp-content 目錄下, 另外需修改 wp-config.php, 加入以下的程式碼:
define('DB_TYPE','sqlite');


Drupal 7 才開始有支援 php data object (PDO) 的 slite 資料庫 (pdo_sqlite),
但我用起來不是很穩, 看起來 drupal7 與 nginx 相容性友有待驗證
須修改 php.ini 的 extension 設定值, 將以下的 extension enable:
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mysql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll

將 nginx 檔案全部放入 c:\nginx
將 php 檔案全部放入 c:\nginx\php

啟動 nginx
start c:\nginx\nginx.exe

命令 php-cgi listen port 9000
start c:\nginx\php\php-cgi.exe -b 127.0.0.1:9000 -c c:\nginx\php\php.ini

沒有留言: