apache php mysql codeigniter smarty 记录方便查询
windows:apache?
restart apache;
?
2.apache:關閉自動目錄列表
#Options Indexes FollowSymLinks#更換為Options -Indexesrestart apache;
?
3.apache:vhosts
a,開啟vhosts
# Virtual hosts Include conf/extra/httpd-vhosts.conf? ? ? ? ? ?b,打開 a中的httpd-vhosts.conf文件添加配置
使用vhosts時,需將httpd.conf中的目錄設置好你所有的vhosts站點的父目錄,否則是無效的;
如:d:/www/web/vhost1
d:/www/web/vhost2
................
d:/www/web/vhost10
則你的httpd.conf?Directory 應該是?d:/www/web/
?
# # Use name-based virtual hosting. # #以下為你所要監控的IP列表 #注意喜歡監控域名的同學在使用CDN的使用你一定要換成監控IP,要不然你懂的 NameVirtualHost XXX.XXX.XX.XX:80 NameVirtualHost X.X.X.X.X:80 <VirtualHost XXX.XXX.XXX.XXX:80>ServerAdmin youmailDocumentRoot "you dir"ServerName you domainErrorLog "you log"CustomLog "you log" common#Redirect permanent / http://轉發domain/ </VirtualHost>當在所有的vhost中找不到相關的配置記錄時,默認返回的是第一個vhost配置。所以要注意這里。
?
更好的方式: virtue hosts map文件方式,自動生成虛擬站點記錄,可以使用腳本(php、jsp或其它)自動生成記錄寫入文件,即時生效無需重啟? ? ? ? ? ? c, restart apache;
?
4,apache:并發調整
a,開啟mpm
# Server-pool management (MPM specific) #開啟mpm Include conf/extra/httpd-mpm.confb,打開 a 中的 httpd-mpm.conf
windows平臺直接找到最后面的 WinNT MPM,以下說明內容來自apache手冊
Apache MPM winnt
| 專門為Windows NT優化過的MPM |
| MPM |
| mpm_winnt_module |
| mpm_winnt.c |
?
?
?
概述
該多路處理模塊(MPM)是Windows NT上的默認值。它使用一個單獨的父進程產生一個單獨的子進程,在這個子進程中輪流產生多個線程來處理請求。
我們需要調整以下的內容,詳細介紹看下面的來自手冊的內容
# WinNT MPM # ThreadsPerChild: constant number of worker threads in the server process # MaxRequestsPerChild: maximum number of requests a server process serves <IfModule mpm_winnt_module>ThreadsPerChild 2000MaxRequestsPerChild 10000 </IfModule>注意:根據你機器的情況調上面的值。但是windows平臺下天生有問題好像,ThreadsPerChild不可設置的過高,就像你機器再好也不要。
求大牛解答,感謝。感謝。
?
ThreadsPerChild 指令
| 每個子進程建立的線程數 |
| ThreadsPerChild number |
| 參見下面的說明 |
| server config |
| MPM |
| mpm_winnt, worker |
?
?
?
?
?
這個指令設置了每個子進程建立的線程數。子進程在啟動時建立這些線程后就不再建立新的線程了。如果使用一個類似于mpm_winnt只有一個子進程的MPM,這個數值要足夠大,以便可以處理可能的請求高峰。如果使用一個類似于worker有多個子進程的MPM,每個子進程所擁有的所有線程的總數要足夠大,以便可以處理可能的請求高峰。
對于mpm_winnt,ThreadsPerChild的默認值是64;對于其他MPM是25。
?
MaxRequestsPerChild 指令
| 每個子進程在其生存期內允許伺服的最大請求數量 |
| MaxRequestsPerChild number |
| MaxRequestsPerChild 10000 |
| server config |
| MPM |
| mpm_netware, mpm_winnt, mpmt_os2, prefork, worker |
?
?
?
?
?
MaxRequestsPerChild指令設置每個子進程在其生存期內允許伺服的最大請求數量。到達MaxRequestsPerChild的限制后,子進程將會結束。如果MaxRequestsPerChild為"0",子進程將永遠不會結束。
不同的默認值
在mpm_netware和mpm_winnt上的默認值是"0"。
將MaxRequestsPerChild設置成非零值有兩個好處:
- 可以防止(偶然的)內存泄漏無限進行,從而耗盡內存。
- 給進程一個有限壽命,從而有助于當服務器負載減輕的時候減少活動進程的數量。
注意
對于KeepAlive鏈接,只有第一個請求會被計數。事實上,它改變了每個子進程限制最大鏈接數量的行為。
?
php mysql mssql?codeigniter smarty
1,php:sockets
我主要與C++通訊,并且通訊的數據包是C++中的結構體。所以采用php pack。
參與以下文章,順便感謝:http://www.neatstudio.com/show-2327-1.shtml
3,php:mysql
這個沒什么好說的。我使用的是codeigniter框架。codeigniter有自己的db class ,有詳細的手冊。
3,php:mssql
同樣,codeigniter有自己的db class,有詳細的手冊。
我的環境環境是 mssql 2008,采用odbc方式。
如下文所例:http://www.taomy.net/codeigniter-%E9%80%9A%E8%BF%87odbc%E8%BF%9E%E6%8E%A5-sqlserver%E7%9A%84%E6%96%B9%E6%B3%95%E5%AE%9E%E4%BE%8B
需要注意的是,如果使用ci的?Active Record 數據庫模式 getwhere mssql數據時,其所生成的sql語句是不附合mssql2008的語法的。需要自己解決。
4,php:codeigniter?
在臨時接手這個項目的時候找了很多的框架,最終相中codeigniter,如其官方宣傳一樣 小巧,易學,輕量,性能不錯,等非常易上手,以至于我臨時啃PHP手冊和codeigniter手冊就能應付來的了。
http://codeigniter.org.cn/
http://codeigniter.org.cn/user_guide/index.html
新浪sae有codeigniter sae上架,,還蠻方便的,寫代碼學習什么的,可以嘗試下
http://sae.sina.com.cn/?m=myapp&a=chooseapp
5,php:codeigniter:smarty
smarty真是好東西。不過現在類似的模板引擎非常多,不過最終還是相中smarty。codeigniter整合smarty也蠻簡單使用起來也很方便。
http://www.smarty.net/
在 http://codeigniter.org.cn/forums/forum.php?搜索也會有一堆的結果。
我的配置方式如下:
?
1,將 Smarty 文件中的 lib 文件夾 ??拷貝至?CodeIgniterh目錄 application\libraries 文件夾下 并重命名smarty lib文件名? 2,在application\libraries目錄中新建文件:,并拷貝如下內容 <?php if(!defined('BASEPATH'))exit('no dir'); require_once (APPPATH.'libraries/Cismarty/Smarty.class.php');class Cismarty extends Smarty {protected $ci;function __construct(){parent::__construct();$this->ci = &get_instance();$this->template_dir = $this->ci->config->item('template_dir');$this->compile_dir = $this->ci->config->item('compile_dir');$this->cache_dir = $this->ci->config->item('caching_dir');$this->config_dir = $this->ci->config->item('config_dir');//$this->template_ext = $this->ci->config->item('template_ext');$this->caching = $this->ci->config->item('caching');$this->cache_lifetime = $this->ci->config->item('cache_lifetime');$this->left_delimiter = $this->ci->config->item('left_delimiter');$this->right_delimiter = $this->ci->config->item('right_delimiter');}} ?>?
3,在application\config目錄中新建,并拷貝如下內容作為配置文件 <?php if (! defined('BASEPATH')) exit('no direct base'); // $config['template_dir'] = APPPATH.'views'; // $config['compile_dir'] = FCPATH.'template_c'; // $config['caching_dir'] = FCPATH.'cache'; // $config['config_dir'] = FCPATH.'config';$config['template_dir'] = APPPATH.'views/templates';$config['compile_dir'] = APPPATH.'views/template_c';$config['caching_dir'] = FCPATH.'cache';$config['config_dir'] = FCPATH.'config';$config['caching'] = false; //是否開啟緩存$config['cache_lifetime'] = '60'; //緩存生存時間(秒)//$config['template_ext'] = '.html';$config['left_delimiter'] = '{!~';$config['right_delimiter'] = '~!}';?>?
4,打開application\config文件,設置自動加載smarty配置文件和加載smarty插件,增加或修改如下內容 $autoload['config'] = array('smarty'); //自動加載配置文件 $autoload['libraries'] = array('cismarty'); //自動每一頁加載smarty模板?
ps.如果不自動加載時可以在需要使用的頁面中調用?$this->load->library('cismarty');進行加載 5,測試程序 a,在application\controllers目錄中新建立控制器??內容如下:? ? ? ?
<?php class Test extends CI_Controller {function __construct(){parent::__construct();//$this->load->library("cismarty");$this->load->library('form_validation');$this->form_validation->set_error_delimiters('<p class="error">', '</p>');}public function index(){$this->cismarty->assign("Name","test name");$this->cismarty->display( 'test.html' );} } ?>?
b,在application\views\templates模板目錄中新建模板文件內容如下: {!~$Name~!} c,輸入 http://localhost/you項目部/index.php/test ?測試效果?
轉載于:https://www.cnblogs.com/ah2710/archive/2013/05/28/3103332.html
總結
以上是生活随笔為你收集整理的apache php mysql codeigniter smarty 记录方便查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 最近老是梦到男朋友出轨是为什么
- 下一篇: DUMPE2FS(8)