php 常用 积累

虚拟主机:

<VirtualHost *:80>

   ServerName  www.a.com

   DocumentRoot 'E:/phpstudy/webpath/a'

   <Directory 'E:/phpstudy/webpath/a'>

     Order deny,allow

     Allow from all

   </Directory>

  </VirtualHost>

ServerName 127.0.0.1

js  ajax   ``

 
<script> 

function paging_s_(page){

  var html_content_s='';

  $.getJSON("{:U('Index/search_action_paging_')}", { p:page, cityChoice: $("#cityChoice").val(),
                                                     sex: $('input:radio:checked').val(),
                                                     age: $('#age_').val()}, function(data){
 
   
                                                                     console.log(data.data);

if(data.status == 1)

{   
$.each(data.data,function(index,item){ 
html_content_s+=`<div class="avatarBox">

<div class="avatarImg"><img src=${item.photo} alt=${item.photo}/>

</div>

<div class="avatarInformation"> 

<a href="__ROOT__/index.php/home/Guestbook/index?id=${item.user_id}" onclick="return access(${item.user_id},${item.encrypt})">查看更多</a>

</div>

</div>`;

})

$("#test_ajax").html(html_content_s);

}

});

}

function paging_(page){ 

htmlobj = $.ajax({

                 type: "GET",

                 url: "{:U('Index/search_ajax_paging')}",

                  data: {

                       p: page,

                          },

                success: function(data) {

 

                    data_ = eval(data);

                     $.each(data_, function(index, item) {

                   html_paging+=`<div class="avatarBox">

                     <div class="avatarImg"><img src=${item.photo} alt=${item.photo}/>

                     </div>

  

<a href="__ROOT__/index.php/home/Guestbook/index?id=${item.user_id}" onclick="return access(${item.user_id},${item.encrypt})">查看更多</a>

 

</div>`;

});

$("#test_ajax").html(html_paging);

}

});

}

</script>
$.ajax({
  type: "POST",
  url: url,
  data: data,
  success: success,
  dataType: dataType
});

$.post( "test.php", { func: "getNameAndTime" }, function( data ) {
  console.log( data.name );  
   
}, "json");

点击事件 下拉列表   单选框 多选框事件

// 为所有button元素的click事件绑定处理函数
$(":button").click( function(event){
    alert( this.value + "-1" );
} );

// 点击链接时,阻止链接跳转
$("a").click( function(){
    return false;
} );

$(document).ready(function(){  
  $("#clickme").click(function(){  
       alert("Hello World  click");  
  });  


$(document).ready(function(){  
  $("#clickme").click(function(){  
       alert("Hello World  click");  
  });  

$(".selector1").change(function(){

     

});
$(".field").change(function(){
  $(this).css("background-color","#FFFFCC");
});


$(".selector").val();
$("div");
$("div,span,p.myClass")
$("#tow").attr("class")//获取ID为tow的class属性
$("#two").attr("class","divClass")//设置Id为two的class属性。

$("#two").addClass("divClass2")为ID为two的对象追加样式divClass2
//3、移除样式
$("#two").removeClass("divClass")移除 ID为two的对象的class名为divClass的样式。
$(#two).removeClass("divClass divClass2")移除多个样式。
//4、切换类名
$("#two").toggleClass("anotherClass") //重复切换anotherClass样式
//5、判断是否含有某项样式
$("#two").hasClass("another")==$("#two").is(".another");
//6、获取css样式中的样式
$("div").css("color") 设置color属性值. $(element).css(style)
//设置单个样式
$("div").css("color","red")
//设置多个样式
$("div").css({fontSize:"30px",color:"red"})
$("div").css("height","30px")==$("div").height("30px")
$("div").css("width","30px")==$("div").height("30px")

thinkphp  配置

return array( 
	/* 模板相关配置 */
    'TMPL_PARSE_STRING' => array(
        '__PUBLIC__'  => __ROOT__ . '/Public',
        '__JS__'      => __ROOT__ . '/Public/Js',
        '__CSS__'     => __ROOT__ . '/Public/Css',
        '__IMAGE__'   => __ROOT__ . '/Public/Img',
        '__DATA__'    => __ROOT__ . '/Data/'
    ),
	//'配置项'=>'配置值' 

	'DB_TYPE'   => 'mysql', // 数据库类型

	'DB_HOST'   => '127.0.0.1', // 服务器地址

	'DB_NAME'   => 'meinhistory', // 数据库名

	'DB_USER'   => 'root', // 用户名

	'DB_PWD'    => 'root', // 密码

	'DB_PORT'   => 3306, // 端口

	'DB_PREFIX' => 'his_', // 数据库表前缀  

	/* 项目设定 */
	'APP_STATUS'            => 'debug',  // 应用调试模式状态
	//'SHOW_PAGE_TRACE'        =>true,   // 显示页面Trace信息
	//'APP_GROUP_LIST'     => 'Home,Admin', //分组设置
	//'APP_SUB_DOMAIN_DEPLOY' => false,    // 是否开启子域名部署
	/* 默认设定 */
	'DEFAULT_LANG'          => 'zh-cn', // 默认语言
	'DEFAULT_THEME'         => 'default',  // 默认分组
	//'DEFAULT_GROUP'      => 'Home',	    	// 默认分组
	'DEFAULT_MODULE'        => 'Index', // 默认模块名称
	//'DEFAULT_ACTION'        => 'index', // 默认操作名称
	//'DEFAULT_AJAX_RETURN'   => 'JSON',  // 默认AJAX 数据返回格式,可选JSON XML ...
	//'DEFAULT_FILTER'        => 'htmlspecialchars', // 默认参数过滤方法 用于 $this->_get|_post('变量名');...


	/* Cookie 设置 */
	//'COOKIE_EXPIRE'         => 3600,    // Cookie有效期

	//'COOKIE_DOMAIN'         => '',      // Cookie有效域名

	//'COOKIE_PATH'           => '/',     // Cookie路径

	//'COOKIE_PREFIX'         => '',      // Cookie前缀 避免冲突





	/* 错误设置 */
	//'ERROR_MESSAGE'         => '您浏览的页面暂时发生了错误!请稍后再试~', //错误显示信息,非调试模式有效

	//'ERROR_PAGE'            => '404.html',	     // 错误定向页面

	//'SHOW_ERROR_MSG'        => true,    // 是否显示具体错误信息  
	/* SESSION设置 */
	//'SESSION_AUTO_START'    => true,    // 是否自动开启Session 

	/* 模板引擎设置 */
	//'TMPL_CONTENT_TYPE'     => 'text/html', // 默认模板输出类型

	'TMPL_TEMPLATE_SUFFIX'  => '.html',     // 默认模板文件后缀

	//'TMPL_FILE_DEPR'=>'/',                  //模板文件模块与操作之间的分割符,只对项目分组部署有效 

	/* URL设置 */
	'URL_CASE_INSENSITIVE'  => true,       // 默认false 表示URL区分大小写 true则表示不区分大小写
	//'URL_MODEL'             => 1,           // URL访问模式,可选参数0、1、2、3,代表四种模式
	//'URL_HTML_SUFFIX'       => '',          // URL伪静态后缀设置 
	/* 系统变量名称设置 */
	//'VAR_GROUP'             => 'g',      // 默认分组获取变量

	//'VAR_MODULE'            => 'm',	     // 默认模块获取变量

	//'VAR_ACTION'            => 'a',	     // 默认操作获取变量

	//错误模板配置

	'TMPL_ACTION_SUCCESS'=>'Public:dispatch_jump',

    'TMPL_ACTION_ERROR'=>'Public:dispatch_jump',

);

thinkphp  form  a

<form action="{:U('Index/search_action_test')}" id="target_form_" method="get" name="form">
        <section class="topSection">
            
        </section>
        <section> 
        </section>
    </form>

link

 <a  href="{:U('Guestbook/index',array('id'=>$vo['user_id']))}" onclick="return access({$vo['user_id']},{$vo['encrypt']})">查看更多test</a>
                    

volist

 

<volist name="list" id="vo">
              <img src="{$vo['photo']}"/> 
                        <ul>
                            <li>姓名:{$vo['user_name']}</li> 
                        </ul>
                        <a  href="{:U('Guestbook/index',array('id'=>$vo['user_id']))}" onclick="return access({$vo['user_id']},{$vo['encrypt']})">查看更多test</a> 
          </volist>

js

<script>
	$(document).ready(function() {
		$("#remember").attr("checked",false);
        $("#remember").change(function() {
             if($('#remember').is(':checked')) {
					$('#rememberme').val('remember');
			}
        }); 
		//鼠标点击自动填充搜索内容 
		$("#uname").keyup(function() {
           // sleep(2); 
            htmlobj = $.ajax({
                type: "GET",
                url: "{:U('Index/zidongtianchong')}",
                data: {
                   search_text: $("#uname").val(),
                    //data: JSON.stringify('userid=1'), 
					//sex: $('input:radio:checked').val() 
                },
                success: function(data) { 
					json_data = eval(data);
                    var html_ = '';
                    $.each(json_data,
                            function(index, item) {
								html_ += '<a href="__URL__/search_action?search_text='+item.user_name+'" ><span>'+item.user_name+'</span></a>';
							});
                    $("#auto_complete").html(html_);				   
                }
            });
        });
	}); 
	//点击登录按钮 
	function sub(){
		 htmlobj = $.ajax({
										type: "post",
										url: "{:U('User/ajax_login_action')}",
										data: { 
											account_name:$('#userName').val(),
											credential:$('#userPwd').val(),
											rememberme:$('#remember_or_not').val(),
										}, 
										success: function(data) { 
										    if(data==1){$.MsgBox.Alert("消息", "登录成功!");}
											else if(data==2){$.MsgBox.Alert("消息", "您已处于登录状态!");}
											else if(data==0){$.MsgBox.Alert("消息", "登录失败!");}
											window.setTimeout("refreshPage()",1500);  

										} 
								});
	}
	//点击搜索

	$( "#history_index_search" ).click(function() {
	//提交表单 
	$( "#target" ).submit();
	});
	</script>

js  上一个节点 下一个节点 next prev 

<script>  
	<!-- 点击更改公开/隐藏 -->
	//全局变量 num 存放 该条记录的id
	var num=0; 
	var text_=''; 
	<!-- 点击公开按钮或隐藏按钮 -->
	$(function(){
     $(".message_box").on("click",".go_open",function(e){
         var this_ =$(e.target);
         console.log(this_); 
         text_=$.trim(this_ .text()).slice(2,4); 
			 <!-- 获取该条记录的id -->
			 num = $(this).next('input').val(); 
			 nid=this_ .prev('input').val();
             var height=this_ .parent().parent().offset().top-330+"px"; 
            $(".alert_open").css({"top":height,"left":"455px"}); 
			 $(".alert_open").show();
        })   
	});
	<!-- 点击警示框确定按钮 ajax回调-->
	$(".click_submit").click(function(){ 
		 var del =$(".alert_open_text").text(); 
		 if(del=='确定要隐藏该信息吗?'||del=='确定要公开该信息吗?'){ 
		   htmlobj = $.ajax({
                type: "GET",
                url: "{:U('User/encrypt_user_')}",
                data: {
                    id: num,  
                }, 
				success: function(data) {
                    test= $.trim($('#'+nid+'').text());
                    console.log(test); 
                    if(test=='点击隐藏'){
                        test=$('#'+nid+'').text('点击公开');
                    }else {
                        test=$('#'+nid+'').text('点击隐藏');
                    };
                    $(".alert_open").hide();                   	 
                } 
            });  

		 }else if(del=='确定要删除吗?'){

				htmlobj = $.ajax({
                type: "GET",
                url: "{:U('User/del_user')}",
                data: {
                    id: num_
                }, 
				success: function(data) {
                    //box_id是外层warp  div 的ID
//                    alert(box_id);
                    $(".alert_open").hide();
					$.MsgBox.Alert("消息", "删除成功!");
					window.setTimeout("refreshPage()",1500);
                     //$("#"+box_id).remove();


                } 
            }); 		
		 }
          	 
	  }); 
      <!-- 点击删除按钮 -->
      $(function(){
     $(".message_box").on("click",".go_delett_",function(e){
             <!-- 获取该条记录的id -->
             var del=$(e.target);
             console.log(del);
			 num_ = del.next('input').val(); 
             box_id=del.prev('input').val(); 
			 <!-- 显示警示框 -->
			 $(".alert_open_text").text('确定要删除吗?');
              var height=del.parent().parent().offset().top-330+"px";
             console.log(height);

             $(".alert_open").css({"top":height,"left":"455px"});
			 $(".alert_open").show();

        })
	}) ;
	  <!-- 点击取消按钮 -->
	   $(".go_close").click(function(){
				$(".alert_open").hide();
		});
 
	 /*$(".message_box").on("click",".go_open",function(e){
    e.preventDefault();
    $(".alert_open").show();
    })

  $(".message_box").on("click",".go_delete",function(e){
   e.preventDefault();
   $(".alert_open_text").html("您确定要删除这条信息的内容吗?")

   $(".alert_open").show();
 })
  $(".go_close").click(function(){
    $(".alert_open").hide();
  })
	$(".click_submit").click(function(){ 
		$(".alert_open").show();
		alert("{$vo['user_id']}");	  
	 return true; 
	  });*/ 
</script>

echarts js

<script>
$('.add').click(function(){ 
  $('.leave_message').fadeToggle();
}) 

/*关系树*/  
      // 路径配置
    require.config({
      paths: {
        echarts: 'http://echarts.baidu.com/build/dist'
      }
    }); 
// 使用
require(
    [
      'echarts',
      'echarts/chart/bar', // 使用柱状图就加载bar模块,按需加载
      'echarts/chart/force',
	  'echarts/chart/tree'
    ],
    function (ec) {
      // 基于准备好的dom,初始化echarts图表
      var myChart = ec.init(document.getElementById('main'));
	 //图表显示提示信息 
		myChart.showLoading({ 
		text: "站点关系图正在努力加载..."
    	});
		myChart.hideLoading();
      var option = {
    title : {
        text: '关系族谱',
        subtext: '线、节点样式'
    },
    tooltip : {
        trigger: 'item',
        formatter: "{b}: {c}"
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: true},
            dataView : {show: true, readOnly: false},
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    calculable : false,

    series : []
};
     


      var ecConfig = require('echarts/config'); 
	   $.ajax({    
				   url: "/html_css/ajax/index/display_data",   	   
					type:'POST',
				    data:{},
					dataType:'json',				
                    success: function(result){ 					
				     myChart.setOption({ 
										series: [
													{
														name:'树图',
                                                        type:'tree',
                                                        orient: 'horizontal',  
                                                        rootLocation: {x: 100, y: '60%'},  
                                                        nodePadding: 20,
                                                        symbol: 'circle',
                                                        symbolSize: 40,
             itemStyle: {
                normal: {
                    label: {
                        show: true,
                        position: 'inside',
                        textStyle: {
                            color: '#cc9999',
                            fontSize: 15,
                            fontWeight:  'bolder'
                        }
                    },
                    lineStyle: {
                        color: '#000',
                        width: 1,
                        type: 'broken' // 'curve'|'broken'|'solid'|'dotted'|'dashed'
                    }
                },
                emphasis: {
                    label: {
                        show: true
                    }
                }
            },
            data:[
						{
									name: "{$account_data_['account_name']}",
									value: 6,
																 
									symbol: "image://{$account_data_['account_photo']}",
																 
								    children: result.data
															}
														]
													}
										]
						});
				  },			
 
				  error: function(){
 
				  }
				  
		});    
    
	});
	function click_div(id_click){ 
				
				 var html = $.ajax({
								   type: "POST",
								   url: "/html_css/ajax/index/click_change_zupu",
								   data:{click_num:id_click},
								   success:function(result){
											$.MsgBox.Alert("消息", "正在展示!"); 
											window.setTimeout("refreshPage()",1500); 
								   }

								}); 
		 }
</script>
 

sql

DROP TABLE IF EXISTS `cms_category`;
CREATE TABLE `cms_category` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL DEFAULT '0',
  `path` text NOT NULL,
  `child_id` text NOT NULL,
  `end_node` int(11) NOT NULL DEFAULT '0',
  `type` varchar(50) NOT NULL DEFAULT '',
  `name` varchar(100) NOT NULL DEFAULT '',
  `pic` varchar(255) NOT NULL DEFAULT '',
  `url` varchar(255) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  `expand` mediumtext NOT NULL,
  `items` int(11) NOT NULL DEFAULT '0',
  `is_article` int(11) NOT NULL DEFAULT '0',
  `viewcount` int(11) NOT NULL DEFAULT '0',
  `storecount` int(11) NOT NULL DEFAULT '0' COMMENT 'shoucangshu',
  `is_show` int(11) NOT NULL DEFAULT '1',
  `sort_no` smallint(6) DEFAULT '100',
  `add_time` int(11) DEFAULT NULL,
  `add_user` int(11) DEFAULT NULL,
  `mod_time` int(11) DEFAULT NULL,
  `mod_user` int(11) DEFAULT NULL,
  `is_delete` int(11) NOT NULL DEFAULT '0',
  `message` text,
  PRIMARY KEY (`id`),
  KEY `pid` (`pid`),
  KEY `storecount` (`storecount`),
  KEY `url` (`url`),
  KEY `is_show` (`is_show`)
) ENGINE=MyISAM AUTO_INCREMENT=366 DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `cms_scene_item`;
CREATE TABLE IF NOT EXISTS `cms_scene_item` (
  `alienid` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) NOT NULL DEFAULT '0',
  `item_type` enum('product','tiyan','fenxiang','huodong','test','zhengji','votes','survey') NOT NULL DEFAULT 'product',
  `scene_id` int(11) NOT NULL DEFAULT '0',
  `partner_id` int(11) NOT NULL DEFAULT '0',
  `add_uid` int(11) NOT NULL DEFAULT '0',
  `add_time` int(11) NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`alienid`),
  KEY `item_id` (`item_id`),
  KEY `partner_id` (`partner_id`),
  KEY `add_time` (`add_time`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

--
-- 转存表中的数据 `cms_scene_item`
--

INSERT INTO `cms_scene_item` (`alienid`, `item_id`, `item_type`, `scene_id`, `partner_id`, `add_uid`, `add_time`, `status`) VALUES
(1, 10012, 'tiyan', 1, 1, 1, 1494937155, 1);

mysql

   net stop mysql

   net start mysql
   mysql -uroot -p
  连接到另外的机器上,则需要加入一个参数-h机器IP
   show databases;
   use mysql;

   show tables;
  导出数据: 
  即将数据库test数据库导出到mysql.test文件,后者是一个文本文件

  如:mysqldump -u root -p123456 --databases dbname > mysql.dbname
  导入数据:

   mysqlimport -u root -p123456 < mysql.dbname
  insert into MYTABLE values ("hyq","M");
  导入.sql文件命令(例如D:/mysql.sql)

  mysql>use database;

  mysql>source d:/mysql.sql;
  连接到远程主机上的MYSQL

假设远程主机的IP为:110.110.110.110,用户名为root,密码为abcd123。则键入以下命令:

  mysql -h110.110.110.110 -uroot -pabcd123                       // 远程登录
  退出MYSQL命令: exit (回车)
  

  alter table tabelname 
    add new_field_id 
    int(5) unsigned default 0 
    not null 
    auto_increment ,
   add primary key (new_field_id);
    
   ALTER TABLE search_record 
   ADD `send` INT default 0;  


二、修改密码
格式:mysqladmin -u用户名 -p旧密码 password 新密码
1、例1:给root加个密码ab12。
 首先在DOS下进入目录mysqlbin,然后键入以下命令:
  mysqladmin -uroot -password ab12 
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
2、例2:再将root的密码改为djg345。
mysqladmin -uroot -pab12 password djg345

显示当前mysql版本和当前日期
select version(),current_date;


2、修改mysql中root的密码:
shell>mysql -u root -p
mysql> update user set password=password(”xueok654123″) where user=’root’;
mysql> flush privileges //刷新数据库
mysql>use dbname; 打开数据库:
mysql>show databases; 显示所有数据库
mysql>show tables; 显示数据库mysql中所有的表:先use mysql;然后
mysql>describe user; 显示表mysql数据库中user表的列信息);

4、mysqldump
备份数据库
shell> mysqldump -h host -u root -p dbname >dbname_backup.sql
恢复数据库
shell> mysqladmin -h myhost -u root -p create dbname
shell> mysqldump -h host -u root -p dbname < dbname_backup.sql

创建临时表:(建立临时表zengchao)
  create temporary table zengchao(name varchar(10));

复制表
  create table table2 select * from table1;

对表重新命名
  alter table table1 rename as table2;
修改列的类型
  alter table table1 modify id int unsigned;//修改列id的类型为int unsigned
  alter table table1 change id sid int unsigned;//修改列id的名字为sid,而且把属性修改为int unsigned

创建索引
  alter table table1 add index ind_id (id);
  create index ind_id on table1 (id);
  create unique index ind_id on table1 (id);//建立唯一性索引



删除索引
  drop index idx_id on table1;
  alter table table1 drop index ind_id;

联合字符或者多个列(将列id与":"和列name和"="连接)
  select concat(id,':',name,'=') from students;



MySQL会使用索引的操作符号
  <,<=,>=,>,=,between,in,不带%或者_开头的like

  分析索引效率
  方法:在一般的SQL语句前加上explain;
  分析结果的含义:
  1)table:表名;
  2)type:连接的类型,(ALL/Range/Ref)。其中ref是最理想的;
  3)possible_keys:查询可以利用的索引名;
  4)key:实际使用的索引;
  5)key_len:索引中被使用部分的长度(字节);
  6)ref:显示列名字或者"const"(不明白什么意思);
  7)rows:显示MySQL认为在找到正确结果之前必须扫描的行数;
  8)extra:MySQL的建议;

使用not null和enum
  尽量将列定义为not null,这样可使数据的出来更快,所需的空间更少,而且在查询时,MySQL不需要检查是否存在特例,即null值,从而优化查询

使用optimize table
   对于经常修改的表,容易产生碎片,使在查询数据库时必须读取更多的磁盘块,降低查询性能。具有可变长的表都存在磁盘碎片问题,这个问题对blob数据类 型更为突出,因为其尺寸变化非常大。可以通过使用optimize table来整理碎片,保证数据库性能不下降,优化那些受碎片影响的数据表。 optimize table可以用于MyISAM和BDB类型的数据表。实际上任何碎片整理方法都是用mysqldump来转存数据表,然后使用转存后的文件并重新建数据 表


使用查询缓存
  1)查询缓存的工作方式:
  第一次执行某条select语句时,服务器记住该查询的文本内容和查询结果,存储在缓存中,下次碰到这个语句时,直接从缓存中返回结果;当更新数据表后,该数据表的任何缓存查询都变成无效的,并且会被丢弃。
  2)配置缓存参数:
   变量:query_cache _type,查询缓存的操作模式。有3中模式,0:不缓存;1:缓存查询,除非与 select sql_no_cache开头;2:根据需要只缓存那些以select sql_cache开头的查询; query_cache_size:设置查询缓存的最大结果集的大小,比这个值大的不会被缓存。



linux下启动mysql的命令:
mysqladmin start
/ect/init.d/mysql start (前面为mysql的安装路径)

linux下重启mysql的命令:
mysqladmin restart
/ect/init.d/mysql restart (前面为mysql的安装路径)


linux下关闭mysql的命令:
mysqladmin shutdown
/ect/init.d/mysql shutdown (前面为mysql的安装路径)


修改mysql密码:
mysqladmin -u用户名 -p旧密码 password 新密码
或进入mysql命令行SET PASSWORD FOR root=PASSWORD("root");

修改mysql密码:
mysqladmin -u用户名 -p旧密码 password 新密码
或进入mysql命令行SET PASSWORD FOR root=PASSWORD("root");

启动:net start mySql;
进入:mysql -u root -p/mysql -h localhost -u root -p databaseName;
  

linux  nginx

 

查看nginx进程  
ps -ef|grep nginx
 
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz 
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.34
./configure
make
make install

cd /usr/local/src
 
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install

 
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz


cd /usr/local/src
wget http://nginx.org/download/nginx-1.4.2.tar.gz
tar -zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
 
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/opt/app/openet/oetal1/chenhe/pcre-8.37 \
--with-zlib=/opt/app/openet/oetal1/chenhe/zlib-1.2.8 \
--with-openssl=/opt/app/openet/oetal1/chenhe/openssl-1.0.1t
 
make
make install

启动
确保系统的 80 端口没被其他程序占用,运行/usr/local/nginx/nginx 命令来启动 Nginx,

 
netstat -ano|grep 80

 
sudo /usr/local/nginx/nginx




apt-get install g++
apt-get install build-essential
make clean
./configure
make

apt-get install openssl
apt-get install libssl-dev


 
yum -y install openssl openssl-devel

nginx启动

sudo /usr/local/nginx/nginx     (nginx二进制文件绝对路径,可以根据自己安装路径实际决定)



nginx从容停止命令,等所有请求结束后关闭服务

ps -ef |grep nginx

kill -QUIT  nginx主进程号

nginx 快速停止命令,立刻关闭nginx进程

ps -ef |grep nginx

kill -TERM nginx主进程号 

如果以上命令不管用,可以强制停止

kill -9 nginx主进程号


nginx重启命令

nginx重启可以分成几种类型

1.简单型,先关闭进程,修改你的配置后,重启进程。
kill -QUIT cat /usr/local/nginx/nginx.pid
sudo /usr/local/nginx/nginx


nginx 服务器重启命令,关闭
nginx -s reload  :修改配置后重新加载生效
nginx -s reopen  :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确 

关闭nginx:
nginx -s stop  :快速停止nginx
         quit  :完整有序的停止nginx

其他的停止nginx 方式:

ps -ef | grep nginx

kill -QUIT 主进程号     :从容停止Nginx
kill -TERM 主进程号     :快速停止Nginx
pkill -9 nginx          :强制停止Nginx



启动nginx:
nginx -c /path/to/nginx.conf

平滑重启nginx:
kill -HUP 主进程号

htaccess

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On 
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteRule ^(admin|center|api|area|pay|group)+\/?$       index.php/$1/$2 [QSA,L]
  RewriteRule ^(admin|center|data|api|area|pay|group)/([a-z]+)-([a-z]+)$       index.php/$1/$2/$3 [QSA,L]

#  RewriteRule ^admin/([a-z]+)-([a-z]+)$       index.php/admin/$1/$2 [QSA,L]
#  RewriteRule ^admin/([a-z]+)-([a-z]+)$       index.php/admin/$1/$2 [QSA,L]
#  RewriteRule ^center/([a-z]+)-([a-z]+)$        index.php/center/$1/$2 [QSA,L]
#  RewriteRule ^api/([a-z]+)-([a-z]+)$           index.php/api/$1/$2 [QSA,L]
#  RewriteRule ^area/([a-z]+)-([a-z]+)$        index.php/area/$1/$2 [QSA,L]
#  RewriteRule ^pay/([a-z]+)-([a-z]+)$           index.php/pay/$1/$2 [QSA,L]
#  RewriteRule ^group/([a-z]+)-([a-z]+)$	index.php/group/$1/$2 [QSA,L]
  RewriteRule ^group/tuan-([0-9]+)$		index.php/group/tuan/index/id/$1 [QSA,L]
  RewriteRule ^([a-z]+)-([a-z]+)$               index.php/home/$1/$2 [QSA,L]

  RewriteRule ^(pinpai|zhuanji|share|special|acthuowu|link|myorder|worthy|corn|cart|rss|sitemap|products|search|keyword|center|thread|adopt|collects|vote|survey|game)+\/?$            index.php/$1 [QSA,L]
  RewriteRule ^product/([0-9a-zA-Z+-]+)$	index.php/products/view/code/$1 [QSA,L]
  RewriteRule ^product/([a-z]+)/(.*)$		index.php/products/$1/$2 [QSA,L]
  RewriteRule ^products/$			index.php/products/index [QSA,L]
  RewriteRule ^products/([0-9]+)$		index.php/products/filter/cid/$1 [QSA,L]
  RewriteRule ^products/([0-9]+)/order/([a-z]+)$     index.php/products/filter/cid/$1/order/$2 [QSA,L]
  RewriteRule ^products/all/order/([a-z]+)$     index.php/products/all/order/$1 [QSA,L]
  RewriteRule ^products/([0-9]+)-([0-9]+)$	index.php/products/filter?cid=$1&cid2=$2 [QSA,L]
  RewriteRule ^products/order/([a-z]+)$		index.php/products/filter?order=$1 [QSA,L]
  RewriteRule ^products/([a-z]+)$		index.php/products/$1 [QSA,L]
  RewriteRule ^preview/([0-9a-zA-Z+-]+)$	index.php/preview/view/code/$1 [QSA,L]
  
  RewriteRule ^special/([0-9]+)$		index.php/special/view/code/$1 [QSA,L]
  RewriteRule ^special/order/(.*)$		index.php/special/index/order/$1 [QSA,L]
  RewriteRule ^special/page/(.*)$		index.php/special/index/page/$1 [QSA,L]


  RewriteRule ^thread/(addpost|addthread|editthread|newthread|info|comment|apply|entrys|delete|edit)$         index.php/thread/$1 [QSA,L]
  RewriteRule ^thread/(addpost|addthread|editthread|comment|apply)/(.*)$         index.php/thread/$1/$2 [QSA,L]
  RewriteRule ^thread/([0-9]+)$			index.php/thread/view/code/$1 [QSA,L]
  RewriteRule ^thread/([0-9]+)/(.*)$            index.php/thread/view/code/$1/$2 [QSA,L]
  
  RewriteRule ^thread/edit/([0-9]+)$            index.php/thread/edit/tid/$1 [QSA,L]
  RewriteRule ^thread/entrys/(joincount)$	index.php/thread/entrys/sort/$1 [QSA,L]
  RewriteRule ^thread/entrys/page/([0-9]+)$	index.php/thread/entrys/page/$1 [QSA,L]
  RewriteRule ^thread/entrys/(joincount|crdate)/page/([0-9]+)$	   index.php/thread/entrys/sort/$1/page/$2 [QSA,L]
  
  RewriteRule ^thread/info/([0-9]+)/page/([0-9]+)$           index.php/thread/info/tid/$1/page/$2 [QSA,L]
  RewriteRule ^thread/newthread/([0-9]+)$       index.php/thread/newthread/tid/$1 [QSA,L]
  RewriteRule ^thread/info/([0-9]+)$            index.php/thread/info/tid/$1 [QSA,L]
  RewriteRule ^thread/delete/([0-9]+)$          index.php/thread/delete/tid/$1 [QSA,L]
  
  RewriteRule ^user/([a-z+_]+)$			index.php/user/$1 [QSA,L]
  RewriteRule ^user-userheader.js$              index.php/user/userheader [QSA,L]
  RewriteRule ^ajax/([a-z]+)$			index.php/ajax/$1 [QSA,L]
  RewriteRule ^article/([a-z0-9]+)$             index.php/article/view/code/$1 [QSA,L]
  RewriteRule ^active/([0-9a-zA-Z+-]+)$		index.php/active/index/code/$1 [QSA,L]

  RewriteRule ^worthy/$				index.php/worthy/index [QSA,L]
  RewriteRule ^worthy/([0-9]+)$			index.php/worthy/view/code/$1 [QSA,L]
  RewriteRule ^worthy/index(.*)$		index.php/worthy/index$1 [QSA,L]
  RewriteRule ^worthy/cate-([0-9]+)(.*)$	index.php/worthy/cate/id/$1$2 [QSA,L]

  RewriteRule ^special/cate-([0-9]+)(.*)$	index.php/special/cate/id/$1$2 [QSA,L]

  RewriteRule ^worthy/page/([0-9]+)$		index.php/worthy/index/page/$1 [QSA,L]
  RewriteRule ^worthy/order/(.*)$		index.php/worthy/index/order/$1 [QSA,L]

  RewriteRule ^space/([a-z0-9]+)$		index.php/space/index/domain/$1 [QSA,L] 
  RewriteRule ^space/([a-z0-9]+)/option/(.*)$       index.php/space/$2/domain/$1/ [QSA,L] 
  RewriteRule ^js/([a-z]+).js$			index.php/js/$1 [QSA,L]
  RewriteRule ^cnc/([a-zA-Z+-]+)$		index.php/cnc/$1 [QSA,L]
  RewriteRule ^activity/([0-9a-zA-Z]+)$		index.php/game/index/code/$1 [QSA,L] 
  RewriteRule ^convert/([0-9]+)$		index.php/convert/convertdetails/id/$1 [QSA,L]
  RewriteRule ^convert/convertdetails/id/([0-9]+)$		index.php/convert/convertdetails/id/$1 [QSA,L]
  RewriteRule ^convert/pay/id/([0-9]+)$		index.php/convert/pay/id/$1 [QSA,L]
  RewriteRule ^convert/moneyconvertentry/(cateid|price|id)/([0-9]+)$		index.php/convert/moneyconvertentry/$1/$2 [QSA,L]
  RewriteRule ^convert/moneyconvertentry/(cateid|price|id|order|sortorder)/([0-9]+)/(cateid|price|id|order|sortorder)/([0-9]+)/(cateid|price|id|order|sortorder)/([0-9]+)$		index.php/convert/moneyconvertentry/$1/$2/$3 [QSA,L]
  RewriteRule ^convert/moneyconvertentry/(cateid|price|id|order|sortorder)/(cateid|price|id|order|sortorder)/(cateid|price|id|order|sortorder)/([0-9]+)$		index.php/convert/moneyconvertentry/$1/$2/$3 [QSA,L]
    
  RewriteRule ^convert/moneyconvertentry/cateid/([0-9]+)/price/([0-9]+)$		index.php/convert/moneyconvertentry/cateid/$1/price/$2 [QSA,L] 
  
  RewriteRule ^data/(edituserdata|datamsgnum|ckcategory|json_crossdata|json_crossdata_week|json_crossdata_day|json_crossdata_month|json_crossdata_year|centerdataweek|init_addtime|centercrossdata|setdefalut|bindingaction|ckbinding|adddata|json_data|json_data_week|json_data_day|json_data_month|json_data_year|centerdataInfo|index|centerdataentry|bindingsub|centerdataset|centerdataentrytoday|centerdatashebei|centerdatainfo|binding|centerdata|centerdatafuli|centerdatainfoalldataentry|centerdatafwentry|centerdatainfopush)$	                index.php/home/Data/$1 [QSA,L]
  RewriteRule ^data/centercrossdata/([0-9]+)/([0-9]+)$	                index.php/home/Data/centercrossdata/id/$1/cross/$2 [QSA,L]
  RewriteRule ^data/centerdatatrans/(health|sports)/([0-9]+)$	                index.php/home/Data/centerdatatrans/type/$1/id/$2 [QSA,L]
  RewriteRule ^data/centerdatainfopush/([0-9]+)$	                index.php/home/Data/centerdatainfopush/id/$1 [QSA,L]
  
  
  RewriteRule ^data/(centerdatatrans|centerdataInfo|centerdataweek|index|centerdataentry|bindingsub|centerdataset|centerdataentrytoday|centerdatashebei|centerdatainfo|binding|centerdata|centerdatafuli|centerdatainfoalldataentry|centerdatafwentry|centerdatainfopush)/([0-9]+)$	                index.php/home/Data/$1/id/$2 [QSA,L]
  
  RewriteRule ^data/centerdatafuli/(baoxian|tijian)$	                index.php/home/Data/centerdatafuli/type/$1 [QSA,L]
  
  
  
  RewriteRule ^data/centerdatashebei/([0-9]+)$	                index.php/home/Data/centerdatashebei/data/$1 [QSA,L]
  RewriteRule ^data/centerdatashebei/data/([0-9]+)$	                index.php/home/Data/centerdatashebei/data/$1 [QSA,L]
  RewriteRule ^data/allddataentryday/([0-9]+)/([0-9]+)$	                index.php/home/Data/allddataentryday/id/$1/time/$2 [QSA,L]
  RewriteRule ^data/allddataentryday$	                index.php/home/Data/allddataentryday [QSA,L]
  RewriteRule ^data/test_data$	                index.php/home/Data/test_data [QSA,L]
  RewriteRule ^data/centerdataentry/(sports|health)$	                index.php/home/Data/centerdataentry/type/$1 [QSA,L]
  
  RewriteRule ^corn/goodsentry$	        index.php/corn/goodsentry 
  RewriteRule ^corn/collects$	        index.php/corn/collects 
  RewriteRule ^corn/goodsdetails/([0-9]+)$	        index.php/corn/goodsdetails/id/$1 
  RewriteRule ^corn/(memberentry|scensentry|moneyentry|discountentry)/(cateid|price|scensid)/([0-9]+)$	        index.php/corn/$1/$2/$3 
  RewriteRule ^corn/(memberentry|scensentry|moneyentry|discountentry)/(cateid|price|scensid)/([0-9]+)/(cateid|price|scensid)/([0-9]+)$	        index.php/corn/$1/$2/$3/$4/$5 
  RewriteRule ^corn/checkbuy$ 	                   index.php/corn/checkbuy 
  RewriteRule ^corn/(getaddr|editaddr|removeaddress|buy|duihuan)$ 	                   index.php/corn/$1 
  RewriteRule ^corn/pay/([0-9]+)$ 	                   index.php/corn/pay/id/$1 
  RewriteRule ^corn/(discountentry|moneyentry|scensentry|memberentry)$  	        index.php/corn/$1 
  RewriteRule ^corn/scensentry/(order|sortorder)/(order|sortorder)/cateid/([0-9]+)$  	        index.php/corn/scensentry/$1/$2/cateid/$3 
  RewriteRule ^corn/(moneyentry|memberentry|scensentry|discountentry)/(order|sortorder)/(order|sortorder)/(cateid|price)/([0-9]+)$  	        index.php/corn/$1/$2/$3/$4/$5 
  RewriteRule ^corn/(scensentry|moneyentry|memberentry|discountentry)/(cateid|price)/([0-9]+)/(order|sortorder)/(order|sortorder)/(price|cateid)/([0-9]+)$  	        index.php/corn/$1/$2/$3/$4/$5/$6/$7 
   
  
  RewriteRule ^link/([0-9]+)$			index.php/link/index/id/$1 [QSA,L]
  RewriteRule ^recommend/([0-9]+)$		index.php/recommend/index/id/$1[QSA,L] 
  
  RewriteRule ^(worthy|search|editor|Do|convert|sitemap|import|Uploads|bonus|sub|voteusers|votes)/([a-zA-Z]+)$            index.php/$1/$2 [QSA,L]
  RewriteRule ^(zhuanji|worthy|special|link|share)/([0-9]+)$         index.php/$1/view/id/$2 [QSA,L]
  RewriteRule ^zhuanji/([0-9a-z]+)$		index.php/zhuanji/view/code/$1 [QSA,L]
  RewriteRule ^zhuanji-([0-9a-z]+)$   index.php/zhuanji/$1 [QSA,L]
  RewriteRule ^(worthy|special|link|share)/([a-z]+)$         index.php/$1/$2 [QSA,L]

  RewriteRule ^adopt/([0-9]+)$			index.php/adopt/info/aid/$1 [QSA,L]
  RewriteRule ^adopt/([a-z]+)$      index.php/adopt/$1 [QSA,L]

  RewriteRule ^collects/([0-9]+)$			index.php/collects/info/aid/$1 [QSA,L]
  RewriteRule ^collects/([a-z]+)$      index.php/collects/$1 [QSA,L]

  RewriteRule ^vote/([0-9]+)$			index.php/vote/info/aid/$1 [QSA,L]
  RewriteRule ^vote/([a-z]+)$              index\.php/vote/$1 [QSA,L] 

  RewriteRule ^survey/([a-z]+)$              index\.php/survey/$1 [QSA,L] 
  RewriteRule ^survey/([0-9]+)$           index\.php/survey/info/id/$1 [QSA,L]
  
  RewriteRule ^theme$			                                index.php/home/theme/index [QSA,L]
  RewriteRule ^theme/([a-z]+)/([0-9]+)$                 index.php/home/theme/$1/id/$2 [QSA,L]
  RewriteRule ^theme/([a-z]+)$                          index.php/home/theme/$1 [QSA,L]
  RewriteRule ^pinpai-([a-z]+)/([0-9]+)$                            index.php/home/pinpai/$1/id/$2
</IfModule>

thinkPHP  入口文件


// 调试模式 建议开发阶段开启 部署阶段注释或者设为false
define('APP_DEBUG',True); 
define('BIND_MODULE','Home');
define('BUILD_CONTROLLER_LIST','Home,Admin,Center'); 
// 应用目录
define('APP_PATH','./App/');
define('TMPL_PATH','./View/');
define('DOMAIN',''); 

config

 return array(
	'MODULE_ALLOW_LIST' => array(	'Home', 
							        'Admin', ),
	'DEFAULT_MODULE'     			=> 'Home', //默认模块
	'DEFAULT_CONTROLLER'     		=> 'Index', //默认模块
	'DEFAULT_ACTION'        		=>  'index',
    'DEFAULT_THEME'				    =>"XX",
	'URL_MODEL'          			=> '1', //URL模式 
    'DB_TYPE'               		=> 'mysql',     // 数据库类型
	'DB_HOST'               		=> 'localhost', // 服务器地址
	'DB_NAME'               		=> 'xxxx', // 数据库名
	'DB_USER'               		=> 'root',      // 用户名
	'DB_PWD'                		=> '',		// 密码
	'DB_PREFIX'             		=> 'test_',		// 数据库表前缀
	
	'SHOW_PAGE_TRACE'			    =>true,			// 显示页面Trace信息
	'URL_CASE_INSENSITIVE'		    =>True,			//URL是否忽略大小写
	'VIEW_CONTROLLER_SUCC'			=>'Common@Pub:success',
	'VIEW_CONTROLLER_FAIL'			=>'Common@Pub:failed',
	'DATA_CACHE_TYPE'			    =>'XX',
	'DATA_CACHE_TIME'			   =>'XX',
	
	'sms'=>array(
		'authname'				=>'TDEST',
		'authcode'				=>'XXXX',
	)
);

html 引入公共

/Pub/Pub/

<include file="Pub@Pub:header" />
<include file="Pub@Pub:menu" />

选中

 

 

转载于:https://my.oschina.net/u/3255899/blog/1141130

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值