PHP 5.3.3 FreeBSD 安裝調整.
by admin on 八月.10, 2010, under FreeBSD, PHP & MYSQL
php 5.3.3之後整合了php-fpm進去對於使用輕量化web server的使用者不再麻煩了.
以下是安裝畫面,安裝選項.
# cd /usr/ports/lang/php5; make install clean;
FreeBSD 上使用 wkhtmltopdf 做網頁擷取
by admin on 八月.04, 2010, under FreeBSD, PHP & MYSQL
以往要用程式控制將網頁輸出pdf或擷取網頁,都是件浩大工程.
這次介紹如何在FreeBSD 命令列模式下即可輕易辦到,並且不需龐大的X Windows 圖形系統適合在server上跑.
以下是軟體原文介紹.
wkhtmltopdf
Convert html to pdf using webkit (qtwebkit)
Description
Simple shell utility to convert html to pdf using the webkit rendering engine, and qt.
Introduction
Searching the web, I have found several command line tools that allow you to convert a HTML-document to a PDF-document, however they all seem to use their own, and rather incomplete rendering engine, resulting in poor quality. Recently QT 4.4 was released with a WebKit widget (WebKit is the engine of Apples Safari, which is a fork of the KDE KHtml), and making a good tool became very easy.
此軟體使用WebKit開發完成,除了flash以外其他接可正常顯示!!(包含js)
在安裝前請先確定你的FreeBSD已安裝 linux-base 套件並正常使用,並且將port tree更新.
(continue reading…)
Zend Framework multidb 不好用我自己來 Mudb
by admin on 四月.27, 2010, under PHP & MYSQL, Zend Framework
源由
Zend Framework 的 multidb 有用過因該知道,只是可以把多跟資料庫加入連結 要用時候在拿出其中之一DB來用.
有做過大型連結資料庫的使用著因該深有同感. 你們常做的動作並不是只要拿其中之一的db來做動作.
這樣動作只有在多個不同資料庫才有用而已.(如同時存取mysql mssql ….)
改進功能
- 讀寫分離.
- 讀取輪詢,分散式負載.
- 多重寫入
看到這邊不知道是否有引起你很大興趣呢?
除了讀寫分離,為何還需要讀取輪詢??
一般常用的資料庫,負載平衡主要也是為了分散負載.
不過你是否有跟我一樣困擾:
- 已經分散了db讀取,卻需要每台server去分配db作為讀取.
- 每台server都要不同的設定檔或環境,增加mis維護成本時間(煩不煩阿).
- 某台slave db掛點,mis還須翻找server對應的db 表作為故障排除.當下還的傷透腦筋不知派哪個db給server用
你的福音來了!!使用他每台db使用固定對應表.
此套件運作模式分為Mw & RW 兩種.
Rw模式
可以設定多個matser和多個slave.
在使用下列取的資料的db function時視為 讀取動作
public function fetchAll($sql, $bind = array(), $fetchMode = null){} public function fetchRow($sql, $bind = array(), $fetchMode = null){} public function fetchAssoc($sql, $bind = array()){} public function fetchCol($sql, $bind = array()){} public function fetchPairs($sql, $bind = array()){} public function fetchOne($sql, $bind = array()){}
在使用下列取的資料的db function時視為 寫入動作
public function insert($table, array $bind) public function update($table, array $bind, $where = '') public function delete($table, $where = '')
看範例說明比較快:
檔案application.ini
; multirwdb Databse setting autoloadernamespaces[] = "Mudb" pluginPaths.Mudb_Application_Resource = "Mudb/Application/Resource" resources.multirwdb.model = "Rw" resources.multirwdb.master[] = "db1" resources.multirwdb.master[] = "db5" resources.multirwdb.slave[] = "db2" resources.multirwdb.slave[] = "db3" resources.multirwdb.slave[] = "db4" resources.multirwdb.db.db1.adapter = "pdo_mysql" resources.multirwdb.db.db1.host = "localhost" resources.multirwdb.db.db1.username = "wacow" resources.multirwdb.db.db1.password = "123456" resources.multirwdb.db.db1.dbname = "wacow" resources.multirwdb.db.db1.charset = "UTF8" resources.multirwdb.db.db1.profiler.enabled = true resources.multirwdb.db.db1.profiler.class = "Zend_Db_Profiler_Firebug" resources.multirwdb.db.db2.adapter = "pdo_mysql" resources.multirwdb.db.db2.host = "localhost" resources.multirwdb.db.db2.username = "wacow" resources.multirwdb.db.db2.password = "123456" resources.multirwdb.db.db2.dbname = "wacow" resources.multirwdb.db.db2.charset = "UTF8" resources.multirwdb.db.db2.profiler.enabled = true resources.multirwdb.db.db2.profiler.class = "Zend_Db_Profiler_Firebug" resources.multirwdb.db.db2.default = true resources.multirwdb.db.db3.adapter = "pdo_mysql" resources.multirwdb.db.db3.host = "localhost" resources.multirwdb.db.db3.username = "wacow" resources.multirwdb.db.db3.password = "123456" resources.multirwdb.db.db3.dbname = "wacow" resources.multirwdb.db.db3.charset = "UTF8" resources.multirwdb.db.db3.profiler.enabled = true resources.multirwdb.db.db3.profiler.class = "Zend_Db_Profiler_Firebug" resources.multirwdb.db.db3.default = true resources.multirwdb.db.db4.adapter = "pdo_mysql" resources.multirwdb.db.db4.host = "localhost" resources.multirwdb.db.db4.username = "wacow" resources.multirwdb.db.db4.password = "123456" resources.multirwdb.db.db4.dbname = "wacow" resources.multirwdb.db.db4.charset = "UTF8" resources.multirwdb.db.db4.profiler.enabled = true resources.multirwdb.db.db4.profiler.class = "Zend_Db_Profiler_Firebug" resources.multirwdb.db.db4.default = true resources.multirwdb.db.db5.adapter = "pdo_mysql" resources.multirwdb.db.db5.host = "localhost" resources.multirwdb.db.db5.username = "wacow" resources.multirwdb.db.db5.password = "123456" resources.multirwdb.db.db5.dbname = "wacow" resources.multirwdb.db.db5.charset = "UTF8" resources.multirwdb.db.db5.profiler.enabled = true resources.multirwdb.db.db5.profiler.class = "Zend_Db_Profiler_Firebug" resources.multirwdb.db.db5.default = true
檔案Bootstrap.php
<?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected $_defaultDb = null; protected $_CacheDB = null; protected $_View = null; protected $_Customer = null; protected function _initDatabase() { if ($this->_defaultDb === null) { if ($this->hasPluginResource('multirwdb')) { $this->bootstrap('multirwdb'); $resource = $this->getPluginResource('multirwdb'); $this->_defaultDb = $resource->getDefaultDb(); }elseif($this->hasPluginResource('db')){ $this->bootstrap('db'); $this->_defaultDb = $this->getPluginResource('db')->getDbAdapter(); } } Zend_Registry::set('db',$this->_defaultDb); } protected function _initZFDebug() { if ($this->_defaultDb === null) { $this->_initDatabase(); } $options = array( 'plugins' => array( 'Html', 'Variables', 'Memory', 'Time', 'Database' => ($this->hasPluginResource('multirwdb')) ? array('adapter' => MuDB_Db::getAllDb()) : array('adapter' => array('default' => $this->_defaultDb)), 'File' => array('base_path' => realpath(APPLICATION_PATH . '/../')), 'Registry', 'Exception', )); $debug = new ZFDebug_Controller_Plugin_Debug($options); $this->bootstrap('frontController'); $frontController = $this->getResource('frontController'); $frontController->registerPlugin($debug); }
檔案IndexController.php
<?php class IndexController extends Zend_Controller_Action { public function init() { $this->db=Zend_Registry::get('db'); } public function indexAction() { $select_test = $this->db->select()->from('system_permissions', '*')->limit(100); $result = $this->db->fetchAll($select_test); $result = $this->db->fetchAll($select_test); $result = $this->db->fetchAll($select_test); $result = $this->db->fetchAll($select_test); $data= array('test' => rand(5, 15)); $this->db->insert('test', $data); } }
執行畫面解說:
在IndexController.php indexAction()下我們只是如同往常對單一的db做讀取動做.
總共做了4次,卻在不同db下查詢完成.
卻可以看到執行畫面下,自動輪詢查詢取的資料.
你是否可以發現程式設計師不用傷透腦筋去更改程式碼即可使用此套件即可完成!!
而寫入動作 $this->db->insert(‘test’, $data);
卻是對全部的MASTER做一併寫入更改!!

Mw模式
Mw模式基本上是Rw延伸
設定檔只存取master部分設定!!!
如範例檔案application.ini
只有db1 db5被引用
並將model改為Mw resources.multirwdb.model = "Mw"
而Mw模式下對db做讀取動做會做輪詢.(每個master都會輪詢等同Rw的slave)
寫入動作則一樣,全部寫入.
注意事項
不再列表的圖取寫入動作則做為對db直接的使用.
Rw模式會限制每個Slave db必須為相同的adapter,此處設限為了避免不小心混用db而渾然不知.
因為很多程式設計師select用法會而不同的資料庫而使用特殊語法.
寫入的特殊應用
而不管為Rw 或MW模式 對於寫入動作則不設限.
此方式可以實現有趣的功能 同時對不同的db來源(如同時對mssql 與mysql做同步更新 不過前提是兩邊資料表必須詳同),做資料同步寫入變更!!!
總結
此套件花了近一個月修改,其中的經驗與處理模式不知是否讓你產生感慨~~
這些經驗都是爆肝來的,如有取用或發佈請保留引用來源.(檔案內並未有版權註解請隨意使用)
到這邊你以為沒了嗎???
其實還有西可以實現,如本來要加入的讀取權重(但是我不能再爆肝了 交由你吧QQ)
為何需要讀取權重??
很多系統會有開發報表等等做大量的資料處理(例如報表)
如果此時有權重分配即可像此套件的使用方式一樣不用額外定義,只需對大量的讀取另做讀取做權重區分!!
感謝收看 再會byby~~
附件檔案:Mudb.tar
Zend Framework + Smarty3 整合應用
by admin on 四月.08, 2010, under PHP & MYSQL, Zend Framework
承上篇 Zend Framework + Smarty2 + Smarty3 整合應用
我曾說過:之前有使用過ZFDebug 感受到整合便利性
所以對之前整合不甚滿意.
來看看最新版本~
將附件內的Smarty3拷貝到你的library目錄內
application.ini
autoloadernamespaces[] = "Smarty3" pluginPaths.Smarty3_Application_Resource = "Smarty3/Application/Resource" resources.smarty.script_path = APPLICATION_PATH "/" resources.smarty.view_suffix = "tpl.htm" resources.smarty.params.left_delimiter = "<%" resources.smarty.params.right_delimiter = "%>" resources.smarty.params.plugins_dir = APPLICATION_PATH "/lib/My/Smarty/plugins" resources.smarty.params.compile_dir = APPLICATION_PATH "/../tmp/compiled" resources.smarty.helper_dirs.key[] = "Zend/View/Helper" resources.smarty.helper_dirs.value[] = "Zend_View_Helper_" ;如果將來需要自己的 View Helper ,可以放在這裡 resources.smarty.helper_dirs.key[] = "My/View/Helper" resources.smarty.helper_dirs.value[] = "My_View_Helper_"
確認好樣板檔案格式,與目錄屬性.
然後Bootstrap.php呢???
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
你已經完成了!
這就是我要的整合~~
附件檔案:ZF_Smarty3.tar
Zend Framework + Smarty2 + Smarty3 整合應用
by admin on 四月.08, 2010, under PHP & MYSQL, Zend Framework
在你開始閱讀前請先前往鐵神:Smarty 2 整合到 Zend Framework 1.10 閱讀完畢並了解.
之前有使用過ZFDebug 感受到整合便利性,於是在整合Sarmty 時想嘗試類似方式做到方便的整合.
Smarty 2
將附件內的Smarty2拷貝到你的library目錄內
在你的application.ini加入
autoloadernamespaces[] = "Smarty2"
Bootstrap.php 範例
<?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initView(){ $view = new Smarty2_View_Smarty (array( 'scriptPath' => APPLICATION_PATH . '/', 'params' => array( 'left_delimiter' => '<%', // 改成你慣用的 'right_delimiter' => '%>', // 改成你慣用的 'plugins_dir' => APPLICATION_PATH . '/library/Smarty2/Smarty/plugins', // 自訂的 Smarty plugins 可以放這裡 'compile_dir' => APPLICATION_PATH . '/../tmp/compiled', ), 'helper_dirs' => array( //'My/View/Helper' => 'My_View_Helper_', // 如果將來需要自己的 View Helper ,可以放在這裡 'Zend/View/Helper' => 'Zend_View_Helper_' ), )); // Controller Plugin Zend_Controller_Front::getInstance()->registerPlugin(new Smarty2_Controller_Plugin_Smarty()); // View Renderer Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer') ->setViewSuffix('tpl.htm') // 可以改成慣用的樣版副檔名 ->setView($view); // Zend Layout $view->layout = Zend_Layout::startMvc(array( 'inflectorTarget' => 'layouts/scripts/:script.:suffix', 'layout' => 'layout', 'viewSuffix' => 'tpl.htm', // 可以改成慣用的樣版副檔名 ))->setView($view); } }
Smarty 3
Smarty3 得特性在浙次整合並沒有發揮,只是先依照以前Smarty2的用法去用而已.
所以與Smarty 2 整合大同小異.
將附件內的Smarty3拷貝到你的library目錄內
在你的application.ini加入
autoloadernamespaces[] = "Smarty3"
Bootstrap.php 範例
<?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initView(){ $view = new Smarty3_View_Smarty (array( 'scriptPath' => APPLICATION_PATH . '/', 'params' => array( 'left_delimiter' => '<%', // 改成你慣用的 'right_delimiter' => '%>', // 改成你慣用的 'plugins_dir' => APPLICATION_PATH . '/library/Smarty3/Smarty/plugins', // 自訂的 Smarty plugins 可以放這裡 'compile_dir' => APPLICATION_PATH . '/../tmp/compiled', ), 'helper_dirs' => array( //'My/View/Helper' => 'My_View_Helper_', // 如果將來需要自己的 View Helper ,可以放在這裡 'Zend/View/Helper' => 'Zend_View_Helper_' ), )); // Controller Plugin Zend_Controller_Front::getInstance()->registerPlugin(new Smarty3_Controller_Plugin_Smarty()); // View Renderer Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer') ->setViewSuffix('tpl.htm') // 可以改成慣用的樣版副檔名 ->setView($view); // Zend Layout $view->layout = Zend_Layout::startMvc(array( 'inflectorTarget' => 'layouts/scripts/:script.:suffix', 'layout' => 'layout', 'viewSuffix' => 'tpl.htm', // 可以改成慣用的樣版副檔名 ))->setView($view); } }
注意如果你於使用中 compile_dir目錄未建置或不可讀寫並且使用ZFDebug.會發現空白頁面並且無任何訊息.
請先參考附件架構.
附件:zf_smarty
筆記 Haproxy 設定
by admin on 四月.07, 2010, under FreeBSD
Haproxy 設定筆記
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
#chroot /var/chroot/haproxy
user haproxy
group haproxy
daemon
#debug
#quiet
nbproc 2 # Number of processes
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 30000
srvtimeout 50000
monitor-uri /ok.html
stats uri /stats
stats auth admin:admin
listen load_balanced_http :80
mode http
option httpchk
option httplog
option forwardfor
option httpclose # disable keep-alive
option checkcache # block response if set-cookie & cacheable
option redispatch
option persist
cookie SERVERID insert nocache indirect
balance roundrobin
server shop1 192.168.0.1:80 cookie server01 weight 49 maxconn 400 check inter 40000
server shop2 192.168.0.2:80 cookie server02 weight 51 maxconn 500 check inter 40000
listen load_balanced_https :443
mode tcp
balance roundrobin
option ssl-hello-chk
option forwardfor
server shop1 192.168.0.1:443 check inter 30000 rise 1 fall 2
server shop2 192.168.0.2:443 check backupZend Famework 1.10.3 + ZFDebug
by admin on 四月.07, 2010, under PHP & MYSQL, Zend Framework
對基本架構不了解可先前往 鐵神: http://www.jaceju.net/blog/?p=1077
此架構為快速架構起始專案的設定
application.ini 內容
[production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 0 ;resources.frontController.noViewRenderer = 1 autoloadernamespaces[] = "ZFDebug" ;Stand Databse setting resources.db.adapter = "pdo_mysql" resources.db.params.host = "localhost" resources.db.params.username = "wacow" resources.db.params.password = "123456" resources.db.params.dbname = "wacow" resources.db.params.charset = "UTF8" resources.db.params.profiler = true ;resources.db.isDefaultTableAdapter = true ; Multidb Databse setting resources.multidb.db1.adapter = "pdo_mysql" resources.multidb.db1.host = "localhost" resources.multidb.db1.username = "wacow" resources.multidb.db1.password = "123456" resources.multidb.db1.dbname = "wacow" resources.multidb.db1.charset = "UTF8" resources.multidb.db1.params.profiler.enabled = true resources.multidb.db1.params.profiler.class = "Zend_Db_Profiler_Firebug" resources.multidb.db2.adapter = "pdo_mysql" resources.multidb.db2.host = "localhost" resources.multidb.db2.username = "wacow" resources.multidb.db2.password = "123456" resources.multidb.db2.dbname = "wacow" resources.multidb.db2.charset = "UTF8" resources.multidb.db2.params.profiler.enabled = true resources.multidb.db2.params.profiler.class = "Zend_Db_Profiler_Firebug" ;resources.multidb.db2.default = true [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1
不同以往 要起始ZFDebug只要加入
autoloadernamespaces[] = "ZFDebug"
並在DB加入 Zend_Db_Profiler_Firebug設定
<?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected $_defaultDb = null; protected function _initDatabase() { if ($this->_defaultDb === null) { if ($this->hasPluginResource('multidb')) { $this->bootstrap('multidb'); $resource = $this->getPluginResource('multidb'); $this->_defaultDb = $resource->getDefaultDb(); }elseif($this->hasPluginResource('db')){ $this->bootstrap('db'); $this->_defaultDb = $this->getPluginResource('db')->getDbAdapter(); }} } protected function _initZFDebug() { $options = array( 'plugins' => array( 'Html', 'Variables', 'File' => array('base_path' => realpath(APPLICATION_PATH . '/../')), 'Memory', 'Time', 'Registry', 'Exception', )); if ($this->_defaultDb === null) { $this->_initDatabase(); } $options['plugins']['Database']['adapter'] = $this->_defaultDb; $debug = new ZFDebug_Controller_Plugin_Debug($options); $this->bootstrap('frontController'); $frontController = $this->getResource('frontController'); $frontController->registerPlugin($debug); } }
_initDatabase() 部份有實座分離單資料庫與多重資料庫的試驗.
其他尚在研究中……………….
FreeBSD NGINX + PHP5
by admin on 三月.30, 2010, under FreeBSD, PHP & MYSQL
先去官網找到freebsd專用的port
http://php-fpm.org/downloads/freebsd-port/
# fetch http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz # mv php-5.2.10-fpm-0.5.13.diff.gz /usr/ports/distfiles/ # fetch http://files.directadmin.com/services/custombuild/php-5.2.9-mail-header.patch # mv php-5.2.9-mail-header.patch /usr/ports/distfiles/ # fetch http://php-fpm.org/downloads/freebsd-port/php-5.2.10-fpm-0.5.13.tar.gz php-5.2.10-fpm-0.5.13.tar.gz 100% of 9503 B 45 kBps # tar zxvf php-5.2.10-fpm-0.5.13.tar.gz -C /usr/ports/lang x php5-fpm/ x php5-fpm/files/ x php5-fpm/Makefile x php5-fpm/distinfo x php5-fpm/pkg-descr x php5-fpm/pkg-plist x php5-fpm/files/php-fpm.sh.in x php5-fpm/files/patch-scripts::phpize.in x php5-fpm/files/patch-TSRM_threads.m4 x php5-fpm/files/patch-Zend::zend.h x php5-fpm/files/patch-Zend_zend_list.c x php5-fpm/files/patch-Zend_zend_list.h x php5-fpm/files/patch-ext_standard_array.c x php5-fpm/files/patch-ext_standard_basic_functions.c x php5-fpm/files/patch-ext_standard_dns.h x php5-fpm/files/patch-ext_standard_image.c x php5-fpm/files/patch-php.ini-dist x php5-fpm/files/patch-php.ini-recommended x php5-fpm/files/patch-main::php_config.h.in x php5-fpm/files/patch-main_SAPI.c x php5-fpm/files/patch-acinclude.m4 x php5-fpm/files/patch-configure.in # cd /usr/ports/lang/php5-fpm/ # make install clean # fetch http://www.grid.net.ru/nginx/download/nginx_upload_module-2.0.12.tar.gz # mv nginx_upload_module-2.0.12.tar.gz /usr/ports/distfiles/ # fetch http://mod-zip.googlecode.com/files/mod_zip-1.1.5.tar.gz # mv mod_zip-1.1.5.tar.gz /usr/ports/distfiles/ # cd /usr/ports/www/nginx-devel # make install clean
編輯/usr/local/etc/php-fpm.conf
nobody改成www
Unix user of processes nobody Unix group of processes nobody
編輯/usr/local/etc/nginx/nginx.conf
#user nobody;
worker_processes 2;
#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;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
#tcp_nopush on;
server_tokens off;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip_static on;
gzip on;
gzip_min_length 1k;
gzip_proxied expired no-cache no-store private auth;
gzip_buffers 4 16k;
gzip_comp_level 5;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
server {
listen 80;
server_name localhost;
autoindex on;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /www;
index index.php index.html index.htm;
}
#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 /usr/local/www/nginx-dist;
}
# 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 /www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www$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;
}
}
server {
listen 80;
server_name test2.localhost www.test2.localhost;
access_log /var/log/test2.access.log;
error_log /var/log/test2.error.log;
location ~* ^.+\.(jpg|jpeg|gif)$ {
root /www/test2/pub;
expires 30d;
}
location ~* ^.+\.(js|css)$ {
root /www/test2/pub;
expires 1h;
}
location / {
root /www/test2/pub;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /www/test2/pub;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/test2/pub$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}編輯/etc/rc.conf
php_fpm_enable="YES" nginx_enable="YES"



















