apache php mysql codeigniter smarty 记录方便查询

windows:apache 

  1. apache:关于apache状态
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>

   restart apache;

 

  2.apache:关闭自动目录列表

    #Options Indexes FollowSymLinks
        #更换为
    Options -Indexes

   restart 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 youmail
    DocumentRoot "you dir"
    ServerName you domain
    ErrorLog "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.conf

    b,打开 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      2000
    MaxRequestsPerChild    10000
</IfModule>

注意:根据你机器的情况调上面的值。但是windows平台下天生有问题好像,ThreadsPerChild不可设置的过高,就像你机器再好也不要。

求大牛解答,感谢。感谢。

 

ThreadsPerChild 指令

说明 每个子进程建立的线程数
语法 ThreadsPerChild number
默认值 参见下面的说明
作用域 server config
状态 MPM
模块 mpm_winnt, worker

 

 

 

 

 

这个指令设置了每个子进程建立的线程数。子进程在启动时建立这些线程后就不再建立新的线程了。如果使用一个类似于mpm_winnt只有一个子进程的MPM,这个数值要足够大,以便可以处理可能的请求高峰。如果使用一个类似于worker有多个子进程的MPM,每个子进程所拥有的所有线程的总数要足够大,以便可以处理可能的请求高峰。

对于mpm_winntThreadsPerChild的默认值是64;对于其他MPM是25

 

MaxRequestsPerChild 指令

说明 每个子进程在其生存期内允许伺服的最大请求数量
语法 MaxRequestsPerChild number
默认值 MaxRequestsPerChild 10000
作用域 server config
状态 MPM
模块 mpm_netware, mpm_winnt, mpmt_os2, prefork, worker

 

 

 

 

 

MaxRequestsPerChild指令设置每个子进程在其生存期内允许伺服的最大请求数量。到达MaxRequestsPerChild的限制后,子进程将会结束。如果MaxRequestsPerChild为"0",子进程将永远不会结束。

不同的默认值

mpm_netwarempm_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  测试效果

 

posted @ 2013-05-28 11:59  ahhhhhhhhh  阅读(302)  评论(0编辑  收藏  举报