快速生成测试环境, 用配置的方式来生成与管理虚拟机

Install

官方文档

  1. cli 
  2. 虚拟机配置文件 
  3. 多个虚拟机配置文件

批量生成示例

进入本地目录, 编辑Vagrantfile, 然后up

 

 

http://www.rabbitmq.com/extensions.html

死信队列

http://www.rabbitmq.com/dlx.html

某些情况可以将这些消息发送到死信队列, 如:

  • 消息被驳回,无把投递
  • 消息过期
  • 超过队列长度

可以通过两种方式设置

  1. 使用参数
  2. 使用策略

策略

http://www.rabbitmq.com/parameters.html#policies

应用或改变队列,exchange的一些属性,比如Queue TTLs, Max queue length等,策略以下以部分组成

  • name
  • pattern, 匹配队列
  • defines, 定义, json格式
  • priority, 优先级

应用目标

Policies can be used to configure the federation plugin, mirrored queues, alternate exchanges,dead lettering, per-queue TTLs, and maximum queue length.

应用场景

http://www.rabbitmq.com/tutorials/tutorial-five-php.html

Amqp协议
php客户端
http://www.rabbitmq.com/queues.html
有效期 http://www.rabbitmq.com/ttl.html

安装教程

Web插件

http://ip:15672/
guest guest

持久化

服务重启时, 是否能恢复队列中的数据.

  • Exchange 持久 durable=True
  • Queue 持久 durable=True
  • Message 持久 delivery_mode = 2,

 使用示例

 

安装参考

  • 安装 https://about.gitlab.com/installation/#centos
  • 配置 https://docs.gitlab.com/omnibus/settings/nginx.html

CI自动集成

示例

项目合并到master的tag提交文件自动上传到远程部署

 

有效期

当一个有效请求发生时,PHP会根据全局变量session.gc_probability/session.gc_divisor的值, 来决定是否启动一个GC(Garbage Collector)。 默认情况下,session.gc_probability = 1,session.gc_divisor =100,也就是说有1%的可能性会启动GC。 GC的工作,就是扫描所有的session信息,用当前时间减去session的最后修改时间(modified date), 同session.gc_maxlifetime参数进行比较,如果生存时间已经超过gc_maxlifetime,就把该session删除。

session服务端相关参数:

  1. session.gc_maxlifetime, 检测
  2. session.gc_probability, 启动gc概率的分子
  3. session.session.gc_divisor, 启动gc概率的分母
  4. session.save_path 为了避免php多次设置不同值,导致部分设置无效,修改此值为不同路径

session客户端相关参数:

  1. session.use_cookies
  2. session.cookie_lifetime

session有效配置参数参考session官方配置

在服务端的存储:

如果你在 session_start() 前调用了 session_name(‘SID’); 那么正常情况下(客户端支持Cookie时), 会给客户端发送 Set-Cookie: SID=(session_id 的值);

以session_id()的值作用存储的键(用作文件名),一个会话的内容以php序列化的值进行存储,如使用memecache进行会话存储了key, 及key_expire, 以下是两个会话的存储情况

Dumping bucket 2 – 2 total items
add sess_p82oq054cm3mh5t0ugf4ho7p32_expire 1 1489398509 10
1489398711
add sess_ir9ld39eo8q0dv9b0qfdbddlu5_expire 1 1489398509 10
1489398625
Dumping bucket 7 – 1 total items
add sess_ir9ld39eo8q0dv9b0qfdbddlu5 0 1489398509 261
__default|a:7:{s:15:”session.counter”;i:8;s:19:”session.timer.start”;i:1489398513;s:18:”session.timer.last”;i:1489398625;s:17:”session.timer.now”;i:1489398625;s:20:”_COLA_CAPTCHA_VALUE_”;s:4:”yKP6″;s:14:”jz.auth.expire”;i:1489434625;s:11:”jz.auth.uid”;s:1:”4″;}
Dumping bucket 8 – 1 total items
add sess_p82oq054cm3mh5t0ugf4ho7p32 0 1489398509 327
__default|a:7:{s:15:”session.counter”;i:2;s:19:”session.timer.start”;i:1489398711;s:18:”session.timer.last”;i:1489398711;s:17:”session.timer.now”;i:1489398711;s:14:”loginBeforeUrl”;s:41:”http://passport1.jz.x1.cn/?q=index&from=1″;s:13:”loginBeforeId”;s:5:”index”;s:15:”session.jsToken”;s:32:”69d660f8fdc72ec55ca647937e425b8a”;}

名词概述

  • satis:
    http://docs.phpcomposer.com/articles/handling-private-packages-with-satis.html
  • 资源包:
    http://docs.phpcomposer.com/02-libraries.html
    http://docs.phpcomposer.com/04-schema.html
  • 资源库:
    http://docs.phpcomposer.com/05-repositories.html

外部dist包存储到私有资源库

statis配置

由于之前未定义require, autoload配置项,导致安装后无法安装相关依赖及配置psr4映射

让composer递归加载包

参考:
http://docs.phpcomposer.com/faqs/why-can%27t-composer-load-repositories-recursively.html

statis配置

 

使用statis

登录252服务器

可以下载一些常用的开源包缓存到公司

生成静态资源包

生成过程中如果需要输入Token, 访问提示的地址, 在github生产新token即可
配置nginx

使用私有包

将安全连接关闭

配置项目composer源


可一并配置git项目用户访问权限

安装包

安装项目


 

了解

  • 资源 https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository
  • 包定义 http://docs.phpcomposer.com/04-schema.html

可安装的资源分类

  • composer 主要的资源库 定义一个 packages.json, 定义各类包及版本, 一个版本可以理解为一个包,必须包括name, version, dist or source, 在dist or source定义路径(type and url), type的取值包括:git, svn, fossil, hg, perforce, zip, rar, tar, gzip, xz , phar, file, path
  • vcs, git仓储/svn, 可以是github、私有git库、svn
  • pear, 不解释
  • package, 没有使用psr规范的普通库

建立自己私有资源库

定义包资源库地址示例