diff --git a/Frontend/README.md b/Frontend/README.md
new file mode 100644
index 0000000..8242710
--- /dev/null
+++ b/Frontend/README.md
@@ -0,0 +1,36 @@
+
+
+
+
+| 操作 | 说明 |
+| ------------ | ------------ |
+| webpack | 打包工具 |
+| underscorejs | 工具库 |
+| lodash | 工具库 |
+| jQuery | JS框架 |
+| Vuejs | 构建用户界面的渐进式框架 |
+| Reactjs | 构建用户界面的JS框架 |
+| Angular | 前端框架 |
+| Sass | CSS扩展语言 |
+
+* x-editable
+ https://github.com/vitalets/x-editable
+
+* wysihtml
+ https://github.com/Voog/wysihtml
+
+* ionicons
+ https://github.com/ionic-team/ionicons
+
+* yarn
+ https://yarnpkg.com/en/docs/install
+
+* datatables
+ https://www.datatables.net/
+
+* momentjs:
+ A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
+ https://github.com/moment/moment/
+
+* fancytree
+https://github.com/mar10/fancytree
diff --git a/Frontend/Webpack-Quick-Start.md b/Frontend/Webpack-Quick-Start.md
new file mode 100644
index 0000000..4747e4f
--- /dev/null
+++ b/Frontend/Webpack-Quick-Start.md
@@ -0,0 +1,62 @@
+Webpack-Quick-Start.md
+
+
+# Installation
+
+使用 NPM 安装:
+
+```
+$ npm install webpack -g
+```
+
+查看安装后的版本:
+
+```
+$ webpack -v
+2.6.1
+```
+
+# Usage
+
+
+$ vi entry.js
+
+```
+document.write("Hello Webpack.");
+```
+
+$ vi index.html
+
+```
+
+
+
+
+
+
+
+
+```
+
+```
+$ webpack ./entry.js bundle.js
+Hash: 32fd78bf2c63bbbf2d1b
+Version: webpack 2.6.1
+Time: 75ms
+ Asset Size Chunks Chunk Names
+bundle.js 2.66 kB 0 [emitted] main
+ [0] ./entry.js 29 bytes {0} [built]
+```
+
+使用浏览器打开 `index.html`, 会输出 `Hello Webpack.`.
+
+
+
+
+npm install --save-dev style-loader css-loader
+
+
+# Reference
+
+https://github.com/webpack/webpack
+https://webpack.js.org/guides
diff --git a/Git-Quick-Start.md b/Git-Quick-Start.md
new file mode 100644
index 0000000..20f5038
--- /dev/null
+++ b/Git-Quick-Start.md
@@ -0,0 +1,498 @@
+Git-Quick-Start.md
+
+Git的基本使用教程
+
+## Git简介
+
+Git是一个分布式的版本控制系统(DVCS, Distributed Version Control Systems).
+
+Git官网: https://git-scm.com/
+Git下载: https://git-scm.com/download/
+
+
+## Git基础命令
+
+获取Git的版本:
+> $ git --version
+
+查看当前分支状态:
+> $ git status
+> $ git status -s
+
+查看变化:
+> $ git diff 查看当前分支的变化
+> $ git diff master origin/master 查看本地master与远程master的变化
+
+查看日志:
+> git log -10
+> git log --all --decorate --graph --pretty=oneline -10
+
+查看分支: 当前分支前面会标一个(*)星号
+> $ git branch
+> $ git branch -a 列出所有分支(包括远程分支)
+> $ git branch -r 列出所有远程分支:
+
+从 origin/master 创建并切换到分支 fea_dev:
+> $ git checkout -b fea_dev origin/master
+
+列出当前的配置:
+git config -l (列出所有的配置)
+git config -l --global (列出所有全局的配置)
+git config -l --local (列出所有本地的配置)
+
+
+## Git常用命令
+
+(1) 分支操作:git branch
+
+查看本地分支: 当前分支前面会标一个(*)星号
+git branch
+
+列出所有分支(包括远程分支)
+git branch -a
+git branch --all
+
+列出所有远程分支:
+git branch -r
+
+
+(2) 将本地更改加入版本追踪: git add
+
+将当前更改或者新增的文件加入到Git的索引中(stage区),即加入版本历史中。
+
+$ git add git.doc.md
+$ git add *
+
+
+(3) 删除文件: git rm
+
+删除文件:
+
+操作示例:
+```
+// 先查看有哪些文件可以删除,但是不真执行删除
+// 参数 -r:递归移除目录
+$ git rm -r -n demo/*
+rm 'demo/README.md'
+rm 'demo/section1.md'
+// 执行删除文件:
+// 通过git status查看这次的删除操作已经可以提交了
+$ git rm -r demo/*
+rm 'demo/README.md'
+rm 'demo/section1.md'
+```
+
+(4) 提交更新: git commit
+提交更新: 将索引内容添加到仓库中(HEAD)
+$ git commit -m "UPDATE:message"
+
+(5) 推送更新: git push:
+将本地分支的更新,推送到远程主机
+$ git push
+$ git push origin master
+
+(6) 切换分支: git checkout
+切换分支: 检出branch分支
+$ git checkout
+$ git checkout -b newBrach origin/master
+
+
+创建并切换分支:
+$ git checkout -b fea_20160506 origin/develope
+git checkout -b develope origin/develope
+
+git checkout dev_branch
+git checkout -b fea_526 origin/fea_526
+
+
+git branch -l
+git checkout -b FEA_MALLSIMP-282 remotes/origin/FEA_MALLSIMP-282
+
+
+(7) 合并分支: git merge
+
+说明: git-merge - Join two or more development histories together
+格式: git merge [from_branch] [to_branch]
+
+
+说明: 合并分支,将 from_branch 分支的代码,合并到 to_branch 分支上
+示例:
+```
+//将origin/develop分支的代码合并到当前分支上
+$ git merge origin/develop
+
+//将master分支的代码合并到dev_branch分支上
+//可以看到:本次合并,提示有冲突,需要解决再提交
+$ git merge master dev_branch
+Auto-merging git.doc.md
+CONFLICT (content): Merge conflict in git.doc.md
+Automatic merge failed; fix conflicts and then commit the result.
+```
+
+(8) 删除分支:
+
+git branch –d [BranchName] // 删除 --delete
+git branch --delete [BranchName] // 删除 --delete
+git branch –D [BranchName] // Shortcut for --delete --force.
+
+* 把一个空分支push到Server上, 即删除该分支
+$ git push origin :
+
+* 删除远程分支
+$ git push --delete origin
+
+操作示例:
+
+```
+ // 删除本地分支,需要先checkout到别的分支,否则会报错
+ $ git branch -d fea_develop
+ error: Cannot delete the branch 'fea_develop' which you are currently on.
+
+ // 切换到master分支,再来删除分支 fea_develop :
+ // 报错: 分支 fea_develop 没有被完全合并
+ // 如果不想合并,可以使用 git branch -D fea_develop 直接删除
+ $ git checkout master
+ $ git branch -d fea_develop
+ error: The branch 'fea_develop' is not fully merged.
+ If you are sure you want to delete it, run 'git branch -D fea_develop'.
+
+ // 现在不想直接删除,把他合并到master主干分支上
+ // 报错: 还是分支 fea_develop 没有被完全合并,还需要合并到远程分支才行
+ $ git merge fea_develop
+ $ git branch -d fea_develop
+ warning: not deleting branch 'fea_develop' that is not yet merged to
+ 'refs/remotes/origin/master', even though it is merged to HEAD.
+ error: The branch 'fea_develop' is not fully merged.
+ If you are sure you want to delete it, run 'git branch -D fea_develop'.
+
+ // 现在不想直接删除,把他合并到master主干分支上,再来删除
+ $ git checkout fea_develop
+ $ git push
+ $ git checkout master
+ $ git merge fea_develop
+ $ git branch -d fea_develop
+ Deleted branch fea_develop (was dcf9d19).
+
+ //删除远程分支:
+ $ git branch -r -d origin/fea_develop
+ Deleted remote-tracking branch origin/fea_develop (was dcf9d19).
+
+ //删除远程分支2:将一个空分支推送到远程,就是删除远程分支了
+ $ git push origin :fea_kaixincms_dev
+ To git@code.wang123.net:code/kaixincms.git
+ - [deleted] fea_kaixincms_dev
+```
+
+
+(9) 重命名分支: git branch –m
+
+git branch –m oldName newName
+
+参数-m,不会覆盖已有分支名称,即如果名为 newName 的分支已经存在,则会提示已经存在了。
+参数-M,就会覆盖已有分支名称,即会强制覆盖名为 newName 的分支
+
+
+(10) 重命名文件: git mv
+
+格式:
+git-mv - Move or rename a file, a directory, or a symlink
+
+操作示例:
+
+创建一个文件,提交到版本库,重命名后再提交到版本库,查看日志
+
+```
+// 创建一个test.txt文件,写入'test.txt'内容
+$ echo 'test.txt' > test.txt
+
+//查看状态:看到文件前有两个问号,说明还被加入版本控制中
+$ git status -s
+?? test.txt
+
+//将文件加入版本控制中
+$ git add *
+$ git commit -m "add test.txt"
+[fea_develop 9b9a163] add test.txt
+ 1 file changed, 1 insertion(+)
+ create mode 100644 test.txt
+
+// 移动文件test.tx,重命名为test_01.txt
+$ git mv test.txt test_01.txt
+// 查看状态:看到文件前有个大写字母R(Rename),表示被重命名
+$ git status -s
+ R test.txt -> test_01.txt
+
+// 提交更新
+$ git add *
+$ git commit -m "rename:test.txt->test02.txt"
+ [fea_develop 80f3288] rename:test.txt->test02.txt
+ 1 file changed, 0 insertions(+), 0 deletions(-)
+ rename test.txt => test_01.txt (100%)
+
+// 查看日志
+$ git log --pretty=oneline
+80f32889999702899109f2e038e3f0a5b2b9efc6 rename:test.txt->test_01.txt
+9b9a16365a6b7fc3ffb0e4c7090d6a85accd4f96 add test.txt
+... ...
+```
+
+
+远程管理:
+
+> 远程管理命令:
+> (1) git clone 克隆操作
+> (2) git remote 远程操作
+> (3) git fetch 远程拉取
+> (4) git pull 远程拉取并合并
+> (5) git push 推送到远程仓库
+
+
+(1) 克隆操作:git clone
+
+说明: 从远程主机克隆一个版本库到本地
+> git-clone - Clone a repository into a new directory
+
+使用:
+
+> git clone https://github.com/wangyongtao/php-dev-docs.git
+
+git remote
+
+$ git remote 列出所有远程主机
+$ git remote -v 列出所有远程主机,并带上网址
+$ git remote show 列出远程主机的详细信息
+$ git remote add 添加远程主机
+$ git remote rm 删除远程主机
+$ git remote rename 远程主机的改名
+
+
+拉取远程分支:git fetch
+
+$ git fetch <远程主机名> 将所有分支数据拉取到本地
+$ git fetch <远程主机名> <分支名> 将制定的分支数据拉取到本地
+
+操作示例:
+```
+//比如,取回origin主机的master分支。
+$ git fetch origin master
+$ git fetch origin master
+From code.test.com:wangyt/dev-docs
+ * branch master -> FETCH_HEAD
+
+//比如,取回origin主机的dev分支。
+$ git fetch origin dev
+From code.test.com:wangyt/dev-docs
+ * branch dev -> FETCH_HEAD
+
+//取回远程主机的更新以后,使用git checkout命令创建一个新的分支:
+//比如,在origin/master的基础上,创建一个新分支newBrach:
+$ git checkout -b newBrach origin/master
+
+```
+
+
+
+git pull:取回远程主机某个分支的更新,再与本地的指定分支合并
+
+格式:git pull <远程主机名> <远程分支名>:<本地分支名>
+
+示例:
+```
+//拉取远程仓库dev分支的更新,并默认与本地当前分支合并
+$ git pull origin dev
+From code.test.com:wangyt/dev-docs
+ * branch dev -> FETCH_HEAD
+Already up-to-date.
+
+//拉取远程仓库master分支的更新,并与指定的本地dev分支合并
+$ git pull origin master:dev
+From code.test.com:wangyt/dev-docs
+ 384f2e8..39995f8 master -> dev
+warning: fetch updated the current branch head.
+fast-forwarding your working tree from
+commit 384f2e848cb57af88c60e66965d9f7d1f6998b16.
+Already up-to-date.
+```
+
+git push : 推送到远程仓库
+
+git push <远程仓库名> <分支名>
+
+
+$ git push
+warning: push.default is unset; its implicit value has changed in
+Git 2.0 from 'matching' to 'simple'.
+使用 matching 参数是 Git 1.x 的默认行为,即如果你执行 git push 但没有指定分支,它将 push 所有你本地的分支到远程仓库中对应匹配的分支。
+而 Git 2.x 默认的是 simple,即执行 git push 没有指定分支时,只有当前分支会被 push 到远程分支。
+
+git stash
+
+git stash list
+
+git stash pop
+
+代码比较: git diff
+
+使用 git diff比较文件的变化,会进入Vi界面状态,输入“:q”退出比较。
+```
+//比较文件git.doc.md的变化:
+$ git diff git.doc.md
+```
+
+查看日志: git log
+
+说明: git-log - Show commit logs
+示例: git log --all --decorate --graph --pretty=oneline -10
+
+查看Git日志:
+$ git log
+
+查看所有日志,每条记录一行:
+> $ git log --pretty=oneline
+
+查看最近10条日志,每条记录一行:
+> $ git log --pretty=oneline -10
+
+查看所有日志,并有图表展示
+> $ git log --all --decorate --graph
+
+查看所有日志,并用图表展示,每条记录一行
+> $ git log --all --decorate --graph --pretty=oneline
+
+恢复本地删除的文件:
+直接从本地把文件checkout出来就可以了,用不着从远程服务器上pull下来,因为,所有的历史版本你的本地都有的。
+具体做法 git checkout file 同时恢复多个被删除的文件:
+git ls-files -d | xargs -i git checkout {}
+
+git reflog 则列出了head曾经指向过的一系列commit
+
+使用 git reflog 查看命令历史
+```
+$ git reflog
+2630090 HEAD@{0}: reset: moving to 2630090
+c585eb1 HEAD@{1}: reset: moving to HEAD^
+2630090 HEAD@{2}: commit: update readme.txt:TEST
+c585eb1 HEAD@{3}: commit: update readme.txt
+6d0aee0 HEAD@{4}: commit (initial): add new file readme.txt
+```
+
+## Git 高阶命令
+
+
+作为merge的替代选择,你可以像下面这样将feature分支并入master分支:
+git checkout feature
+git rebase master
+
+它会把整个feature分支移动到master分支的后面,有效地把所有master分支上新的提交并入过来。
+但是,rebase为原分支上每一个提交创建一个新的提交,重写了项目历史,并且不会带来合并提交。
+
+合并多个提交:
+
+$ git rebase –i HEAD~3
+
+(1) git rebase –i HEAD~3
+(2) 将第二个及以后的 pick 修改为 s (squash),然后输入“:x”(或“:wq”)保存并退出
+(3) 这时git会自动第二个提交合并到第一个中去,并提示输入新的comments,修改后输入“:x”(或“:wq”)保存并退出
+(4) 此时本地的(HEAD中)最后多次的提交已经被合并为一个提交。
+如果需要提交到远程仓库,运行git push --force origin master即可。
+
+* 修改提交的注释内容:
+> 使用 --amend 参数,进入文本编辑界面,修改内容后重新保存即可
+> $ git commit --amend
+
+
+* git blame
+
+git-blame - Show what revision and author last modified each line of a file
+
+
+
+
+## 配置
+
+列出当前的配置:
+
+git config -l
+git config --global
+git config --local
+
+设置邮箱和用户名:
+如果没有配置邮箱与用户名,提交时会提示配置:
+ ```
+ $ git commit -m "Add configure.php.dev.env.md"
+ *** Please tell me who you are.
+ Run
+ git config --global user.email "you@example.com"
+ git config --global user.name "Your Name"
+```
+
+```
+//全局的设置
+$ git config --global user.email "ahwyt2008@foxmail.com"
+$ git config --global user.name "WangYongTao"
+```
+
+```
+//局部的设置
+$ git config --local user.email "ahwyt2008@163.com"
+$ git config --local user.name "WANG-YongTao"
+```
+
+git config --global push.default simple
+
+
+## 常用问题
+
+$ git push
+fatal: The current branch fea_20160506 has no upstream branch.
+To push the current branch and set the remote as upstream, use
+ git push --set-upstream origin fea_20160506
+
+如何删除中文名的文件:
+> 在使用git status的时候,会发现中文文件名无法正常显示:
+> deleted: "\345\246\202\344\275\225\345\256\211\350\243\205PHP.md"
+>
+> 正常显示中文,让Git不对中文文件名进行处理:
+> $ git config --global core.quotepath false
+>
+> 运行 git status,可以看到中文正常显示了。
+> deleted: "如何安装PHP.md"
+>
+> 但是,无法使用 git rm [name] 来删除该文件:
+> 可以运行 git add -u 将所有改动的文件提交到暂存区,制定删除文件名,直接提交就可以了。
+> $ git add -u
+
+
+## Git教程
+
+1. 官方教程:《Pro Git : 2nd Edition (2014)》
+https://git-scm.com/book/en/v2
+https://git-scm.com/book/zh (中文版)
+
+2. 廖雪峰的官方网站:《Git教程》
+http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
+
+3. 易佰:《Git教程》
+http://www.yiibai.com/git/
+
+Git远程操作详解
+http://www.ruanyifeng.com/blog/2014/06/git_remote.html
+
+
+
+## 参考链接
+
+1. https://git-scm.com/
+2. http://www.liaoxuefeng.com/
+3. http://www.yiibai.com/
+4. http://www.ruanyifeng.com/blog/2014/06/git_remote.html
+5. http://www.cnblogs.com/itech/p/5188932.html
+...
+
+
+## 更新记录
+
+2016-05-17: 新增一些问题
+2016-05-30: 完善补充内容
+
+[END]
diff --git a/README.md b/README.md
index 1e1447b..459ea76 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,38 @@
### php-developement-guide
-PHP开发教程
+PHP开发教程笔记
The PHP Developement Guide in Chinese
-
-Linux
-Nginx
-MySQL
-PHP
-HTML/CSS
-JavaScript
-jQuery
+
+* [Chapter1 基础](chapter1_basic/README.md)
+ * [Install-安装PHP开发环境 ](chapter1_basic/Install-安装Nginx服务器.md)
+ * [Install-安装Nginx服务器 ](chapter1_basic/Install-安装PHP开发环境.md)
+ * [Git基本使用教程 ](chapter1_basic/Git基本使用教程.md)
+
+* [Linux](chapter5_linux/README.md)
+ * [Install-安装PHP开发环境 ](chapter1/Install-安装PHP开发环境.md)
+ * [Install-安装Nginx服务器 ](chapter1/Install-安装Nginx服务器.md)
+ * [Git基本使用教程 ](chapter1/Git基本使用教程.md)
+
+Git-Quick-Start.md
计划:
1. phpDocumentor
+
+
+
+Knowledge-Systems
+
+
+
+
+
+
+
+
+* 终端工具 iTerm2
+iTerm2 是 MAC 下最好的终端工具, 开源免费,自带分屏功能(集成了tumx)
+
+## 参考资料
+
+PHP之道 [PHP: The Right Way](https://phptherightway.com/)
diff --git a/SUMMARY.md b/SUMMARY.md
index a16b8ee..4524371 100644
--- a/SUMMARY.md
+++ b/SUMMARY.md
@@ -1,11 +1,7 @@
# SUMMARY
-* [Chapter1 PHP基础](chapter1/README.md)
- * [Section1.1](chapter1/section1.1.md)
- * [Section1.2](chapter1/section1.2.md)
-* [Chapter2 PHP实践](chapter2/README.md)
- * [Section2.1](chapter2/section2.1.md)
- * [Section2.2](chapter2/section2.2.md)
-* [Chapter3 PHP](chapter3/README.md)
- * [Section3.1](chapter3/section3.1.md)
- * [Section3.2](chapter3/section3.2.md)
+* [安装与配置](installation/README.md)
+
+* [PHP](php-quick-start/README.md)
+
+* [Linux](linux-quick-start/README.md)
diff --git a/Vim-Quick-Start.md b/Vim-Quick-Start.md
new file mode 100644
index 0000000..65f7dc2
--- /dev/null
+++ b/Vim-Quick-Start.md
@@ -0,0 +1,106 @@
+vim-quick-start.md
+
+Vim是从 vi 发展出来的一个文本编辑器。
+
+vi/vim 的使用
+
+基本上 vi/vim 共分为三种模式: 分别是命令模式(Command mode),插入模式(Insert mode)和底线命令模式(Last line mode)。
+
+(1) 命令模式(Command mode)
+
+用户刚刚启动 vi/vim,便进入了命令模式。
+控制屏幕光标的移动,字符、字或行的删除,移动复制某区段及进入Insert mode下,或者到 last line mode。
+
+i 切换到插入模式,以输入字符。
+x 删除当前光标所在处的字符。
+: 切换到底线命令模式,以在最底一行输入命令。
+
+进入插入或取代的编辑模式:
+
+i, I 进入插入模式(Insert mode):
+i 为『从目前光标所在处插入』
+I 为『在目前所在行的第一个非空格符处开始插入』。 (常用)
+
+a, A 进入插入模式(Insert mode):
+a 为『从目前光标所在的下一个字符处开始插入』
+A 为『从光标所在行的最后一个字符处开始插入』。(常用)
+
+o, O 进入插入模式(Insert mode):
+这是英文字母 o 的大小写。
+o 为『在目前光标所在的下一行处插入新的一行』
+O 为在目前光标所在处的上一行插入新的一行!(常用)
+
+r, R 进入取代模式(Replace mode):
+r 只会取代光标所在的那一个字符一次;
+R会一直取代光标所在的文字,直到按下 ESC 为止;(常用)
+
+(2) 插入模式/编辑模式(Insert mode)
+
+只有在Insert mode下,才可以做文字输入,按「ESC」键可回到命令行模式。
+
+BACKSPACE,退格键,删除光标前一个字符
+DELETE,删除键,删除光标后一个字符
+ENTER,回车键,换行
+ESC,退出输入模式,切换到命令模式
+方向键,在文本中移动光标
+
+(3) 底线命令模式(Last line mode)
+
+将文件保存或退出vi,也可以设置编辑环境,如寻找字符串、列出行号等。
+
+在命令模式下按下`:`(英文冒号)就进入了底线命令模式。
+按`ESC`键可随时退出底线命令模式。
+
+:q 退出程序
+:w 保存文件
+:wq 保存并退出
+:q! 强制退出,不保存
+:x 保存并退出 (同:wq)
+
+进入vi的命令
+
+vi filename :打开或新建文件,并将光标置于第一行首
+vi +n filename :打开文件,并将光标置于第n行首
+vi + filename :打开文件,并将光标置于最后一行首
+vi +/pattern filename:打开文件,并将光标置于第一个与pattern匹配的串处
+vi -r filename :在上次正用vi编辑时发生系统崩溃,恢复filename
+vi filename....filename :打开多个文件,依次进行编辑
+
+
+h 或 向左箭头键(←) 光标向左移动一个字符
+j 或 向下箭头键(↓) 光标向下移动一个字符
+k 或 向上箭头键(↑) 光标向上移动一个字符
+l 或 向右箭头键(→) 光标向右移动一个字符
+
+
+:set nu 显示行号,设定之后,会在每一行的前缀显示该行的行号
+:set nonu
+
+
+| 操作 | 说明 | 备注 |
+| ---- | ------------ | ------------ |
+| `0` | 到本行行头 | 数字0键 |
+| `^` | 到本行第一个非空字符 | 上箭头(即数字6键) |
+| `$` | 到本行行尾 | 美元符号(即数字4键) |
+| `g_` | 到本行最后一个非空字符 | 小写字母g+下划线符号 |
+| `fa` | 到下一个为(a)的字符 | 小写字母f + 其他字符 |
+| `t.` | 到(点号)前的第一个字符 | 小写字母t + 其他字符 |
+
+* 删除所有行: `:%d` (冒号 + 百分号 + 小写字母d)
+
+- 跳到文本的最后一行:按字母 `G`, 即`shift+g`
+- 跳到最后一行的最后一个字符: 先即按`G`(即`shift`+`g`),之后按`$`键(即`shift`+`4`)。
+
+- 跳到第一行的第一个字符: 先按两次小写字母“g”
+- 跳转到当前行的第一个字符:在当前行按“0”
+
+问: vim 如何复制多行文本?
+答: 在命令模式下,将光标移动到将要复制的首行处,按`nyy`复制n行;其中n为1、2、3……
+
+
+# Reference:
+
+http://www.vim.org/
+http://www.study-area.org/tips/vim/
+http://www.jianshu.com/p/bcbe916f97e1
+http://blog.jobbole.com/18339/
\ No newline at end of file
diff --git "a/chapter1_basic/Install-nginx\344\270\216php-fpm\351\205\215\347\275\256.md" "b/chapter1_basic/Install-nginx\344\270\216php-fpm\351\205\215\347\275\256.md"
new file mode 100644
index 0000000..fd013ad
--- /dev/null
+++ "b/chapter1_basic/Install-nginx\344\270\216php-fpm\351\205\215\347\275\256.md"
@@ -0,0 +1,42 @@
+
+安装php和php-fpm
+这里我使用的php7版本,目前官方已经发布了php7的beta3版本。
+php-fpm已经被包含在里面了,无需另外安装.
+
+安装nginx
+
+#启动php-fpm,mac必须要以root用户启动,-R 参数表示 --allow-to-run-as-root
+sudo /usr/local/php7/sbin/php-fpm -R
+
+
+sudo /data/webserver/php7/sbin/php-fpm -R
+
+
+sudo /usr/local/webserver/nginx/nginx -t
+
+重新加载:
+$ sudo /usr/local/webserver/nginx/nginx -s reload
+
+
+http://localhost/phpinfo.php
+
+/data/webserver/php7/etc/php-fpm.d/www-data.conf
+指定了监听端口:
+
+listen = 127.0.0.1:9000
+
+
+/usr/local/webserver/nginx/nginx.conf
+```
+location ~ \.php$ {
+ root /usr/local/webserver/nginx/html;
+ fastcgi_pass 127.0.0.1:9000;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ include fastcgi_params;
+}
+```
+
+## 参考链接:
+
+https://segmentfault.com/a/1190000003067656
\ No newline at end of file
diff --git "a/chapter1_basic/Install-\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md" "b/chapter1_basic/Install-\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md"
new file mode 100644
index 0000000..b4c5a29
--- /dev/null
+++ "b/chapter1_basic/Install-\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md"
@@ -0,0 +1,358 @@
+源码编译安装Nginx服务器
+
+Compiling and Installing From the Sources
+
+
+## 1 安装前准备:
+
+1-1 检测本地环境:
+```
+$ sw_vers
+ProductName: Mac OS X
+ProductVersion: 10.11.3
+BuildVersion: 15D21
+
+$ uname -mnprs
+Darwin MacWangYongTao.local 15.3.0 x86_64 i386
+```
+
+1-2 检测GCC版本:
+```
+$ gcc -v
+Configured with:
+--prefix=/Applications/Xcode.app/Contents/Developer/usr
+--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
+Apple LLVM version 7.0.2 (clang-700.1.81)
+Target: x86_64-apple-darwin15.3.0
+Thread model: posix
+```
+
+1-3 创建安装目录/webserver:
+
+为了方便管理,在/usr/local/下新建一个目录webserver,以后软件安装都可以加"—prefix=/usr/loca/webserver"来安装到这个目录下:
+
+```
+$sudo mkdir webserver
+$pwd
+/usr/local/webserver
+```
+
+# 2 安装nginx的依赖库
+
+### 安装pcre:
+
+PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 Perl兼容的 正则表达式库,由菲利普.海泽(Philip Hazel)编写。
+
+
+the PCRE library – required by NGINX Core and Rewrite modules and provides support for regular expressions:
+
+```
+wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.bz2
+tar jxvf pcre-8.38.tar.bz2
+cd pcre-8.38
+./configure --prefix=/usr/local/webserver/pcre-8.38
+make
+make test
+sudo make install
+```
+
+### 安装zlib:
+
+zlib是提供数据压缩用的函式库,目前zlib是一种事实上的业界标准,最新版本是:zlib 1.2.8(April 28, 2013)。
+
+zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression).
+
+the zlib library – required by NGINX Gzip module for headers compression:
+
+```
+wget http://zlib.net/zlib-1.2.8.tar.gz
+tar zxvf zlib-1.2.8.tar.gz
+cd zlib-1.2.8
+./configure --prefix=/usr/local/webserver/zlib
+make
+make test
+sudo make install
+```
+
+### 安装openssl:
+
+OpenSSL 是一个强大的安全套接字层密码库,包括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
+
+the OpenSSL library – required by NGINX SSL modules to support the HTTPS protocol:
+
+```
+$ wget http://www.openssl.org/source/openssl-1.0.2e.tar.gz
+$ tar -zxf openssl-1.0.2e.tar.gz
+$ cd openssl-1.0.2e
+$ ./Configure darwin64-x86_64-cc --prefix=/usr/local/webserver/openssl --openssldir=/usr/local/webserver/openssl
+$ make
+$ sudo make install
+
+查看版本(检测是否安装成功):
+$ /usr/local/webserver/openssl/bin/openssl version
+OpenSSL 1.0.2h 3 May 2016
+
+
+查看OpenSSL支持的平台列表:
+$./Configure LIST
+
+```
+
+注意事项:
+> If configuring for 64-bit OS X, then use a command similar to:
+> $./Configure darwin64-x86_64-cc shared enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macos-x86_64
+> $make depend
+> $sudo make install
+>
+> If configuring for 32-bit OS X, then use a command similar to:
+> ./Configure darwin-i386-cc shared no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macosx-i386
+> $make depend
+> $sudo make install
+
+
+
+## 3 安装Nginx
+
+下载并安装Nginx:
+
+```
+// 指定安装在/usr/local/webserver/目录下:
+$ wget http://nginx.org/download/nginx-1.8.1.tar.gz
+$ tar zxf nginx-1.8.1.tar.gz
+$ export KERNEL_BITS=64
+$ ./configure --prefix=/usr/local/webserver/nginx \
+ --sbin-path=/usr/local/webserver/nginx/nginx \
+ --conf-path=/usr/local/webserver/nginx/nginx.conf \
+ --pid-path=/usr/local/webserver/nginx/nginx.pid \
+ --with-http_ssl_module \
+ --with-openssl=../openssl-1.0.2h \
+ --with-pcre=../pcre-8.38 \
+ --with-zlib=../zlib-1.2.8
+```
+
+参数说明:
+
+--sbin-path=path — 设置可执行文件名. 默认是:prefix/sbin/nginx.
+--conf-path=path — 设置配置文件名(nginx.conf). 默认是:prefix/conf/nginx.conf.
+--pid-path=path — 设置存放进程ID的nginx.pid文件名.默认是:prefix/logs/nginx.pid.
+--with-http_ssl_module - 启用支持https协议,依赖OpenSSL库.
+--with-pcre=path - sets the path to the sources of the PCRE library.(注意是源码的路径)
+--with-zlib=path — sets the path to the sources of the zlib library.(注意是源码的路径)
+
+
+## 4 配置Nginx:
+
+配置文件路径: /usr/local/webserver/nginx/nginx.conf
+
+$ sudo /usr/local/webserver/nginx/nginx -t
+nginx: the configuration file /usr/local/webserver/nginx/nginx.conf syntax is ok
+nginx: configuration file /usr/local/webserver/nginx/nginx.conf test is successful
+
+## 5 启动Nginx:
+
+查看版本:
+```
+$ /usr/local/webserver/nginx/nginx -v
+nginx version: nginx/1.8.1
+```
+
+执行启动命令:
+```
+// 启动Nginx,没有报错可以认为启动成功
+$ sudo /usr/local/webserver/nginx/nginx
+```
+
+
+命令查看:
+
+```
+$ curl -I 127.0.0.1
+HTTP/1.1 200 OK
+Server: nginx/1.8.1
+Date: Mon, 01 Feb 2016 12:29:30 GMT
+Content-Type: text/html
+Content-Length: 612
+Last-Modified: Mon, 01 Feb 2016 10:25:21 GMT
+Connection: keep-alive
+ETag: "56af3291-264"
+Accept-Ranges: bytes
+```
+
+浏览器查看:
+
+打开浏览器输入:http://127.0.0.1/ 或者 http://localhost/
+可以看到:"Welcome to nginx! " 页面
+
+其实,这个页面是在 /usr/local/webserver/nginx/html/ 目录下,
+我们尝试新建一个html静态页面:
+```
+$ pwd
+/usr/local/webserver/nginx/html
+$ sudo vi hello.html
+...(随便写入一下内容,比如"Hello,Nginx!",然后保存)..
+
+```
+
+打开浏览器输入:
+http://127.0.0.1/hello.html 或者 http://localhost/hello.html
+可以看到我们刚刚写的静态页面hello.html的内容。
+
+现在Nginx只支持一些静态的内容,如果需要动态内容,还需要安装PHP等。
+
+重新加载:
+$ sudo /usr/local/webserver/nginx/nginx -s reload
+
+
+## 遇到的问题与解决办法
+
+### 报错1: 没有指定 OpenSSL 库.
+
+内容:
+```
+./configure: error: SSL modules require the OpenSSL library.
+You can either do not enable the modules, or install the OpenSSL library
+into the system, or build the OpenSSL library statically from the source
+with nginx by using --with-openssl= option.
+```
+分析: 启用with-http_ssl_module模块,但没有启用openssl, 启用的SSL模块需要依赖openssl库
+解决: configure时增加参数 [with-openssl=../openssl-1.0.2e].
+
+
+### 报错2: 参数配置路径出错
+
+参数with-pcre,如果指定的是with-pcre=/usr/local/webserver/pcre-8.38,则执行 make 时会报错:
+
+```
+/Applications/Xcode.app/Contents/Developer/usr/bin/make -f objs/Makefile
+cd /usr/local/pcre-8.38 \
+ && if [ -f Makefile ]; then /Applications/Xcode.app/Contents/Developer/usr/bin/make distclean; fi \
+ && CC="cc" CFLAGS="-O2 -pipe " \
+ ./configure --disable-shared
+/bin/sh: ./configure: No such file or directory
+make[1]: *** [/usr/local/webserver/pcre-8.38/Makefile] Error 127
+make: *** [build] Error 2
+```
+
+分析: set path to PCRE library sources, 注意是PCRE的源代码的路径,不是编译安装后的路径
+```
+查看配置帮助:
+$ ./configure --help | grep 'pcre'
+ --without-pcre disable PCRE library usage
+ --with-pcre force PCRE library usage
+ --with-pcre=DIR set path to PCRE library sources
+ --with-pcre-opt=OPTIONS set additional build options for PCRE
+ --with-pcre-jit build PCRE with JIT compilation support
+```
+
+注意这里的路径是 PCRE library sources, 是PCRE的源代码。
+直接去官网下载PCRE, 解压至与 nginx-1.8.1 平级的目录中(或者其他的路径)。
+
+解决: 将PCRE路径指定为源代码的路径,比如:with-pcre=/softwares/pcre-8.38
+
+### 报错3 :
+$ sudo ./config --prefix=/usr/local/openssl
+Operating system: i686-apple-darwinDarwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015;
+root:xnu-3248.30.4~1/RELEASE_X86_64
+WARNING! If you wish to build 64-bit library, then you have to
+ invoke './Configure darwin64-x86_64-cc' *manually*.
+ You have about 5 seconds to press Ctrl-C to abort.
+
+解决: 配置命令使用 Configure, 而不是config, 加参数平台参数:darwin64-x86_64-cc
+$ sudo ./Configure darwin64-x86_64-cc --prefix=/usr/local/openssl
+备注: 查看支持的平台列表:$./Configure LIST
+
+### 报错4:Undefined symbols for architecture x86_64
+
+```
+Undefined symbols for architecture x86_64:
+ "_SSL_CTX_set_alpn_select_cb", referenced from:
+ _ngx_http_ssl_merge_srv_conf in ngx_http_ssl_module.o
+ "_SSL_CTX_set_next_protos_advertised_cb", referenced from:
+ _ngx_http_ssl_merge_srv_conf in ngx_http_ssl_module.o
+ "_SSL_select_next_proto", referenced from:
+ _ngx_http_ssl_alpn_select in ngx_http_ssl_module.o
+ "_X509_check_host", referenced from:
+ _ngx_ssl_check_host in ngx_event_openssl.o
+ld: symbol(s) not found for architecture x86_64
+clang: error: linker command failed with exit code 1 (use -v to see invocation)
+make[1]: *** [objs/nginx] Error 1
+make: *** [build] Error 2
+
+```
+分析: 这个报错在网上有好多种原因造成的,因此也有许多的解决办的。
+只要系统是64位系统,然后configure前在指明一下是64位系统,就没问题了。
+解决:
+(1)将openssl-1.0.2e目录中, 文件Makefile中的[darwin-i386-cc]全部替换成[darwin64-x86_64-cc]
+(2)检测自己的系统是以32位模式运行,还是以64位模式运行,确保是以64位模式运行。
+(3)要为当前启动磁盘选择 64 位内核,请在“终端”中使用下列命令:sudo systemsetup -setkernelbootarchitecture x86_64
+```
+// 但是设置没有生效:
+$ sudo systemsetup -setkernelbootarchitecture x86_64
+Password:
+setting kernel architecture to: x86_64
+changes to kernel architecture failed to save!
+```
+(4) 执行配置NGINX命令前,增加 export KERNEL_BITS=64 命令,指定系统的运行模式为64位的。
+
+### 报错5: 重启NGIXN报错:
+内容:
+nginx: [error] open() "/usr/local/webserver/nginx/nginx.pid" failed (2: No such file or directory)
+
+分析:
+解决:使用nginx -c的参数指定nginx.conf文件的位置:
+/usr/local/webserver/nginx/nginx -c /usr/local/webserver/nginx/nginx.conf
+
+注意这里的nginx路径,在编译时有指定,可能像网上的有些不同,默认应该是:
+/usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
+
+```
+检测配置文件是否正确: (出错了,没有找到nginx.conf文件)
+$ sudo /usr/local/webserver/nginx/nginx -t
+nginx: [emerg] open() "/usr/local/webserver/nginx/nginx.conf" failed (2: No such file or directory)
+nginx: configuration file /usr/local/webserver/nginx/nginx.conf test failed
+
+复制配置文件:(复制一份)
+$sudo cp nginx.conf.default nginx.conf
+
+再次检测: (OK)
+$ sudo /usr/local/webserver/nginx/nginx -t
+nginx: the configuration file /usr/local/webserver/nginx/nginx.conf syntax is ok
+nginx: configuration file /usr/local/webserver/nginx/nginx.conf test is successful
+```
+
+
+## 用到的一些命令
+
+```
+$ ps -ef |grep nginx
+$ kill -9 [pid]
+$ arch
+$ uname -a
+$ ioreg -l -p IODeviceTree | grep "firmware-abi" | sed -e 's/[^0-9A-Z]//g'
+
+```
+
+
+## 参考资料
+
+http://nginx.org/en/docs/configure.html
+
+https://www.nginx.com/resources/admin-guide/installing-nginx-open-source/
+
+http://segmentfault.com/a/1190000003822041?_ea=392297
+
+http://lists.apple.com/archives/macnetworkprog/2015/Jun/msg00025.html
+
+http://www.iyunv.com/thread-18789-1-1.html
+
+https://wiki.openssl.org/index.php/Compilation_and_Installation#Mac
+
+http://www.nooidea.com/2011/02/switch-mac-into-64-bit.html
+
+
+## 更新记录
+
+Update 2016/01/28: Updated for nginx-1.8.1.
+Update 2016/05/17: 更新到openssl-1.0.2h,修改一些内容.
+
+[END]
diff --git "a/chapter1_basic/\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md" "b/chapter1_basic/Install-\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md"
similarity index 84%
rename from "chapter1_basic/\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md"
rename to "chapter1_basic/Install-\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md"
index ccbde71..267876d 100644
--- "a/chapter1_basic/\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md"
+++ "b/chapter1_basic/Install-\345\256\211\350\243\205PHP\345\274\200\345\217\221\347\216\257\345\242\203.md"
@@ -9,43 +9,51 @@
但是若需要与标准配置不同的功能(例如一个安全服务器,或者不同的数据库驱动扩展模块),可能需要编译 PHP 和/或 web 服务器。
如果不熟悉编译软件,可以考虑搜索一下是否有人已经编译了包含所需要功能的预编译包。
-### PHP开发环境包括什么?
+### PHP开发环境包括什么
+服务器: Nginx, Apache
+语言:PHP
+数据库: MySQL, Sqlite, MongoDB, Redis
+缓存: Memcache, Redis
-### 如何安装PHP开发环境?
+
+### 如何安装PHP开发环境
1 使用一键安装包:
Windows系统:
-PHPStudy:
-http://www.phpstudy.net/
+> PHPStudy:
+> http://www.phpstudy.net/
-AppServ:
-http://www.appservnetwork.com/en/
+> AppServ:
+> http://www.appservnetwork.com/en/
-WampServer:
-http://www.wampserver.com/
+> WampServer:
+> http://www.wampserver.com/
-UPUPW:
-http://www.upupw.net/
+> UPUPW:
+> http://www.upupw.net/
-XAMPP:支持Windows/Linux/MacOS平台
-https://www.apachefriends.org/zh_cn/index.html
+> XAMPP:支持Windows/Linux/MacOS平台
+> https://www.apachefriends.org/zh_cn/index.html
Linux系统:
-http://lnmp.org/
-http://www.lanmps.com/
-XAMPP:支持Windows/Linux/MacOS平台
-https://www.apachefriends.org/zh_cn/index.html
+> http://lnmp.org/
+> http://www.lanmps.com/
+> XAMPP:支持Windows/Linux/MacOS平台
+> https://www.apachefriends.org/zh_cn/index.html
2 使用源码编译安装:
+Linux: CentOS, Ubuntu
+Mac: OS X
+
+### 如何使用源码编译安装PHP环境
-### 如何使用源码编译安装PHP环境?
> + OpenSSl
> + Mcrypt
> + zlib
@@ -220,14 +228,28 @@ Mac-mini:php-5.6.9 WangTom$
```
# 报错: curl
+执行configure配置时报错:
... ...
checking whether to enable ctype functions... yes
checking for cURL support... yes
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
-Mac-mini:php-5.6.9 WangTom$
+$
```
+curl-7.49.0.tar.bz2 (7.1M)
+$ wget https://curl.haxx.se/download/curl-7.49.0.tar.bz2
+$ wget http://www.execve.net/curl/curl-7.49.0.tar.bz2 (备选下载地址)
+$ tar jxf curl-7.49.0.tar.bz2
+$ cd curl-7.49.0
+$ ./configure --prefix=/usr/local/webserver/curl
+$ make
+$ sudo make install
+
+$ /usr/local/webserver/curl/bin/curl -V
+curl 7.49.0 (x86_64-apple-darwin15.3.0) libcurl/7.49.0 zlib/1.2.5
+Protocols: dict file ftp gopher http imap ldap ldaps pop3 rtsp smtp telnet tftp
+Features: IPv6 Largefile libz UnixSockets
diff --git "a/chapter1_basic/PHP-Laravel-Homestead\345\274\200\345\217\221\347\216\257\345\242\203\345\256\211\350\243\205\344\270\216\351\205\215\347\275\256.md" "b/chapter1_basic/PHP-Laravel-Homestead\345\274\200\345\217\221\347\216\257\345\242\203\345\256\211\350\243\205\344\270\216\351\205\215\347\275\256.md"
new file mode 100644
index 0000000..a7ea8e4
--- /dev/null
+++ "b/chapter1_basic/PHP-Laravel-Homestead\345\274\200\345\217\221\347\216\257\345\242\203\345\256\211\350\243\205\344\270\216\351\205\215\347\275\256.md"
@@ -0,0 +1,289 @@
+# PHP Laravel-Homestead 开发环境安装与配置
+
+> Laravel Homestead 是一个官方预载的 Vagrant「封装包」,提供你一个美好的开发环境,不需要在本机端安装 PHP、HHVM、网页服务器或任何服务器软件。
+> Homestead 可以在任何 Windows、Mac 或 Linux 上面运行,里面包含了 Nginx 网页服务器、PHP 5.6、MySQL、Postgres、Redis、Memcached等软件,
+> 还有所有你要开发精彩的 Laravel 应用程序所需的软件。
+
+### 本机系统环境:
+
+```
+//使用 uname 查看当前操作系统名称
+$ uname -mnprs
+Darwin YONG-TEST.local 15.6.0 x86_64 i386
+
+//使用sw_vers 查看 macOS版本信息
+$ sw_vers
+ProductName: Mac OS X
+ProductVersion: 10.11.6
+BuildVersion: 15G31
+```
+
+### 不使用用Homestead,直接在本机安装:
+
+使用homebrew安装PHP7:
+
+$ brew update
+$ brew search php70
+homebrew/php/php70
+homebrew/php/php70-gmagick
+homebrew/php/php70-maxminddb
+homebrew/php/php70-pdo-pgsql
+homebrew/php/php70-stats
+homebrew/php/php70-amqp
+...
+
+$ brew install homebrew/php/php70
+
+配置php-fpm端口为9002, 因为本机已经安装了php5, 占用了9001端口。
+
+配置Nginx配置文件:
+
+重启Nginx服务器。
+
+
+### 安装Homestead Vagrant Box:
+
+下载 Homestead:
+
+```
+$ git clone https://github.com/laravel/homestead.git Homestead
+$ cd Homestead/
+$ ls
+CHANGELOG.md Vagrantfile composer.lock init.bat readme.md /src
+LICENSE.txt composer.json homestead init.sh /scripts
+$ bash init.sh
+```
+
+下载 Homestead Vagrant Box:
+
+$ vagrant box add laravel/homestead
+
+执行示例:
+
+```
+//下载安装laravel/homestead:
+$ vagrant box add laravel/homestead --force
+==> box: Loading metadata for box 'laravel/homestead'
+box: URL: https://atlas.hashicorp.com/laravel/homestead
+==> box: Adding box 'laravel/homestead' (v0.5.0) for provider: virtualbox
+box: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.5.0/providers/virtualbox.box
+box: Progress: 5% (Rate: 572k/s, Estimated time remaining: 0:33:13)
+...
+
+//下载成功后显示如下:
+==> box: Successfully added box 'laravel/homestead' (v0.5.0) for 'virtualbox'!
+```
+
+### 启动虚拟机
+
+```
+$ vagrant up
+Bringing machine 'default' up with 'virtualbox' provider...
+There are errors in the configuration of this machine. Please fix the following errors and try again:
+vm: * The host path of the shared folder is missing: ~/Code
+//报错没有“~/Code”目录,那我们就创建一个:
+$ mkdir ~/Code
+$ vagrant up
+```
+
+打开VirtualBox中,可以看到有一个名为"homestead-7"的虚拟机正在运行(状态为:Running)。
+
+
+### 配置Hosts文件:
+
+```
+$ sudo vi /etc/hosts
+//增加一条记录:
+192.168.10.10 homestead.app
+```
+
+Make sure the IP address listed is the one set in your ~/.homestead/Homestead.yaml file.
+
+
+### 使用laravel创建一个站点:
+
+$ cd ~/Code
+$ composer require laravel/homestead --dev
+
+配置文件“Homestead.yaml”里包含一个示例站点配置.
+注意默认的站点是"/home/vagrant/Code/Laravel/public",
+所以我们现在创建在~/Code下面创建一个名为"Laravel"。
+
+$ laravel new Laravel
+-bash: laravel: command not found
+
+$ ~/.composer/vendor/bin/laravel new Laravel
+
+/home/vagrant/Code/Laravel/public
+
+打开浏览器,输入"http://homestead.app/", 即可正常访问。
+
+
+### 配置 Homestead
+
+配置文件路径是: ~/.homestead/Homestead.yaml
+
+配置文件内容如下:
+```
+ip: "192.168.10.10"
+memory: 2048
+cpus: 1
+provider: virtualbox
+authorize: ~/.ssh/id_rsa.pub
+keys:
+ - ~/.ssh/id_rsa
+folders:
+ - map: ~/Code
+ to: /home/vagrant/Code
+sites:
+ - map: homestead.app
+ to: /home/vagrant/Code/Laravel/public
+databases:
+ - homestead
+```
+
+配置示例: 新增一个网站"kaixin123.app":
+
+(1) 新增网站目录"kaixin123net":
+ 在Code目录中新增一个kaixin123net目录,作为新增网站的根目录:
+ 创建一个index.html文件,随便写写内容,比如"hello,kaixin123.app":
+ 路径如下: ~/Code/kaixin123net/index.html
+
+(2) 增加sites:
+```
+$ vim ~/.homestead/Homestead.yaml
+
+//在sites中新增一条map记录,修改后配置如下:
+//配置中的xunij “/home/vagrant/Code/kaixin123net” 对应我们本地的 "~/Code/kaixin123net"
+sites:
+ ### 默认
+ - map: homestead.app
+ to: /home/vagrant/Code/Laravel/public
+ ### 新增加一个网站,域名为kaixin123.app
+ - map: kaixin123.app
+ to: /home/vagrant/Code/kaixin123net
+```
+(3) 新增一条host记录:
+```
+$ sudo vim /etc/hosts
+
+//新增一条host记录,IP是Homestead.yaml中“ip”,修改后如下:
+... (略) ...
+192.168.10.10 homestead.app
+192.168.10.10 kaixin123.app
+
+```
+(4) 打开浏览器,输入"http://kaixin123.app/", 可以正常访问。
+
+如果重新修改配置,需要重新加载vagrant:
+
+```
+$ cd /Users/WangTom/Homestead
+$ vagrant reload --provision
+```
+
+登录虚拟机:
+
+$ cd ~/Homestead/
+$ vagrant ssh
+
+```
+/进入~/Homestead/目录
+YONGTEST:~ WangTom$ cd ~/Homestead/
+YONGTEST:Homestead WangTom$
+
+//登录虚拟机
+YONGTEST:Homestead WangTom$ vagrant ssh
+Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)
+ * Documentation: https://help.ubuntu.com/
+Last login: Fri Sep 23 06:42:33 2016 from 10.0.2.2
+
+//有Code文件夹,这个/home/vagrant/Code与本机的~/Code目录会保持同步
+vagrant@homestead:~$ ls
+Code
+
+//退出虚拟机
+vagrant@homestead:~$ exit
+logout
+Connection to 127.0.0.1 closed.
+```
+
+
+连接Homestead数据库:
+
+>
+> To connect to your MySQL or Postgres database from your host machine via Navicat or Sequel Pro:
+> Connect to 127.0.0.1 and port 33060 (MySQL) or 54320 (Postgres).
+> The username and password for both databases is homestead / secret.
+
+地址: 192.168.10.10
+端口: 3306
+用户名: homestead
+密码: secret
+
+
+登录虚拟机数据库:
+
+```
+vagrant@homestead:~$ mysql -h192.168.10.10 -uhomestead -p
+Enter password:
+Welcome to the MySQL monitor. Commands end with ; or \g.
+Your MySQL connection id is 51
+Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu)
+Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+Oracle is a registered trademark of Oracle Corporation and/or its
+affiliates. Other names may be trademarks of their respective
+owners.
+Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
+mysql> show databases;
++--------------------+
+| Database |
++--------------------+
+| information_schema |
+| homestead |
+| mysql |
+| performance_schema |
+| sys |
++--------------------+
+5 rows in set (0.00 sec)
+mysql>
+```
+
+以后再次启动/登录:
+$ cd ~/Homestead/
+$ vagrant up
+$ vagrant ssh
+
+
+### 扩展阅读
+
+(1) brew
+
+brew(即Homebrew), 是macOS上的软件包管理工具, 能在Mac中方便的安装软件或者卸载软件,类似ubuntu系统下的apt-get的功能.
+Homebrew- The missing package manager for OS X
+http://brew.sh/
+
+(2) Vagrant
+
+Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境。它使用Oracle的开源VirtualBox虚拟化系统,使用Chef创建自动化虚拟环境。
+https://www.vagrantup.com/
+
+(3) Laravel
+
+Laravel是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。
+https://laravel.com/
+
+
+### 参考资料
+
+https://laravel.com/docs/5.3/homestead
+http://laravelacademy.org/post/2749.html
+http://laravel-china.org/docs/5.1/homestead
+https://www.vagrantup.com/docs/getting-started/
+
+
+### 更新记录
+
+1. 20160825 新增此文档 (wangyt)
+2. 20160829 更新文档,改成Homestead安装与配置 (wangyt)
+3. 20160922 更新文档,新增配置多站点 (wangyt)
diff --git "a/chapter1_basic/PHP7_\345\256\211\350\243\205.md" "b/chapter1_basic/PHP7_\345\256\211\350\243\205.md"
index cc21402..0806357 100644
--- "a/chapter1_basic/PHP7_\345\256\211\350\243\205.md"
+++ "b/chapter1_basic/PHP7_\345\256\211\350\243\205.md"
@@ -4,7 +4,7 @@ php7-install.md
2015年6月11日,PHP官网发布消息,正式公开发布PHP7第一版的alpha版本.
-### PHP7特性:
+## PHP7特性:
PHP 7.0.0 Alpha 1使用新版的ZendEngine引擎,带来了许多新的特性,以下是不完全列表:
(1)性能提升:PHP7比PHP5.6性能提升了两倍。 Improved performance: PHP 7 is up to twice as fast as PHP 5.6
@@ -17,25 +17,52 @@ PHP 7.0.0 Alpha 1使用新版的ZendEngine引擎,带来了许多新的特性
(8)新增加了标量类型声明。Scalar Type Declarations
(9)新增加匿名类。Anonymous Classes
-### 系统环境:
+## 系统环境:
```
-Mac-mini:~ WangTom$ uname -mnprs
+$ uname -mnprs
Darwin Mac-mini.local 14.3.0 x86_64 i386
-Mac-mini:~ WangTom$ sw_vers
+$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.3
BuildVersion: 14D136
```
-### 源码安装PHP7:
+## 源码安装PHP7:
PHP7下载地址:https://downloads.php.net/~ab/
-
+最新版本(10-May-2016 15:44): https://downloads.php.net/~ab/php-7.0.7RC1.tar.bz2
```
-$ wget https://downloads.php.net/~ab/php-7.0.0alpha1.tar.bz2
-$ tar jxf php-7.0.0alpha1.tar.bz2
-$ cd php-7.0.0alpha1
+$ wget https://downloads.php.net/~ab/php-7.0.7RC1.tar.bz2
+$ tar jxf php-7.0.7RC1.tar.bz2
+$ cd php-7.0.7RC1
+
+$ ./configure --prefix=/usr/local/webserver/php7 \
+--with-config-file-path=/usr/local/webserver/php7 \
+--with-mysqli \
+--enable-pdo \
+--with-pdo-mysql \
+--with-mysql-sock=/usr/local/mysql/data/WangTomdeMBP.pid \
+--enable-cgi \
+--enable-fpm \
+--enable-sockets \
+--enable-mbstring \
+--enable-mbregex \
+--enable-bcmath \
+--enable-xml \
+--enable-zip \
+--enable-opcache \
+--with-zlib=/usr/local/lib/zlib \
+--with-gd \
+--with-curl=/usr/local/webserver/curl \
+--disable-iconv
+
+--with-iconv=/usr/local/libiconv \
+
+
+参数选项"--enable-mbstring" :激活 mbstring 函数。 要使用 mbstring 函数必须启用这个选项。
+
+--disable-iconv
$ ./configure
... ...
@@ -48,6 +75,18 @@ configure: error: Please specify the install prefix of iconv with --with-iconv=<
```
+CFLAGS='-arch x86_64' CCFLAGS='-arch x86_64' CXXFLAGS='-arch x86_64'
+
+ARCHFLAGS="-arch x86_64"
+
+参数with-mysql-sock:
+获取MySQL的pid路径:
+$ ps -ef |grep mysql
+可以看到结果中:“--pid-file=/usr/local/mysql/data/WangTomdeMBP.pid”
+
+参数“enable-opcache”,此参数选项在php5.5及以后版本自带
+
+
安装 libiconv (字符编码转换库)
网站地址: http://www.gnu.org/software/libiconv/
当前版本: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
@@ -56,9 +95,14 @@ configure: error: Please specify the install prefix of iconv with --with-iconv=<
$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
$ tar zxf libiconv-1.14.tar.gz
$ cd libiconv-1.14
-$ ./configure --prefix=/usr/local/lib/libiconv
+$ ./configure --prefix=/usr/local/webserver/libiconv
$ make
$ sudo make install
+
+$ /usr/local/webserver/libiconv/bin/iconv --version
+iconv (GNU libiconv 1.14)
+Copyright (C) 2000-2011 Free Software Foundation, Inc.
+
```
@@ -66,8 +110,8 @@ $ sudo make install
```
$ ./configure --prefix=/usr/local/php7 \
--enable-fpm \
---with-config-file-path=/usr/local/php7/etc \
---with-iconv=/usr/local/lib/libiconv \
+--with-config-file-path=/usr/local/php7 \
+--with-iconv=/usr/local/webserver/libiconv \
执行configure配置后,可以看到有如下结果:
... ...
@@ -93,67 +137,148 @@ $ sudo make install
查看PHP7是否安装成功
````
-WangTomdeMacBook-Pro:php-7.0.0alpha1 wangtom$ /usr/local/php7/bin/php -v
-PHP 7.0.0alpha1 (cli) (built: Jun 20 2015 00:04:19)
-Copyright (c) 1997-2015 The PHP Group
-Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
+$ /usr/local/webserver/php7/bin/php -v
+PHP 7.0.7RC1 (cli) (built: May 22 2016 19:14:03) ( NTS )
+Copyright (c) 1997-2016 The PHP Group
+Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
+
+设置环境变量php7
+$ sudo ln -s /usr/local/webserver/php7/bin/php /usr/local/bin/php7
+注意新版本的OSX系统不能指定到/usr/bin/下,指定到/usr/local/bin/下即可。
-Mac-mini:~ WangTom$ sudo ln -s /usr/local/php7/bin/php /usr/bin/php7
+> //原来可以使用:
+> //$ sudo ln -s /usr/local/webserver/php7/bin/php /usr/bin/php7
+> 因为系统默认开启了“系统完整性保护,System Integrity Protection (SIP)”
+> $ csrutil status
+> System Integrity Protection status: enabled.
-Mac-mini:~ WangTom$ php -v
+
+$ php -v
PHP 5.5.20 (cli) (built: Feb 25 2015 23:30:53)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
-Mac-mini:~ WangTom$ php7 -v
-PHP 7.0.0alpha1 (cli) (built: Jun 23 2015 17:24:34)
-Copyright (c) 1997-2015 The PHP Group
-Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
+$ php7 -v
+PHP 7.0.7RC1 (cli) (built: May 22 2016 19:14:03) ( NTS )
+Copyright (c) 1997-2016 The PHP Group
+Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
-Mac-mini:php-fpm.d WangTom$ which php
+$ which php
/usr/bin/php
-Mac-mini:php-fpm.d WangTom$ which php7
+$ which php7
/usr/bin/php7
```
-### 配置PHP-FPM:
+报错:Undefined symbols for architecture x86_64
+错误信息:
+```
+Undefined symbols for architecture x86_64:
+ "_libiconv", referenced from:
+ _zif_iconv_substr in iconv.o
+ _zif_iconv_mime_encode in iconv.o
+ _php_iconv_string in iconv.o
+ __php_iconv_strlen in iconv.o
+ __php_iconv_strpos in iconv.o
+ __php_iconv_appendl in iconv.o
+ _php_iconv_stream_filter_append_bucket in iconv.o
+ ...
+ "_libiconv_close", referenced from:
+ _zif_iconv_substr in iconv.o
+ _zif_iconv_mime_encode in iconv.o
+ _php_iconv_string in iconv.o
+ __php_iconv_strlen in iconv.o
+ __php_iconv_strpos in iconv.o
+ __php_iconv_mime_decode in iconv.o
+ _php_iconv_stream_filter_factory_create in iconv.o
+ ...
+ "_libiconv_open", referenced from:
+ _zif_iconv_substr in iconv.o
+ _zif_iconv_mime_encode in iconv.o
+ _php_iconv_string in iconv.o
+ __php_iconv_strlen in iconv.o
+ __php_iconv_strpos in iconv.o
+ __php_iconv_mime_decode in iconv.o
+ _php_iconv_stream_filter_factory_create in iconv.o
+ ...
+ld: symbol(s) not found for architecture x86_64
+clang: error: linker command failed with exit code 1 (use -v to see invocation)
+make: *** [sapi/cli/php] Error 1
+```
+解决办法: 目前还没有解决,先将选项参数"--with-iconv=/usr/local/libiconv"改成"--disable-iconv"。
+
+
+## 配置PHP-FPM:
Nginx不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用。
PHP-FPM是一个PHP FastCGI管理器,新版的PHP已经集成了php-fpm,在./configure的时候带 –enable-fpm参数即可开启PHP-FPM.
FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites.
+/usr/local/webserver/php7/
+/usr/local/webserver/php7/sbin/php-fpm
+
启动 PHP-FPM:
```
-Mac-mini:php7 WangTom$ /usr/local/php7/sbin/php-fpm
-[23-Jun-2015 15:33:01] WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf' from /usr/local/php7/etc/php-fpm.conf at line 125.
-[23-Jun-2015 15:33:01] ERROR: failed to open error_log (/usr/local/php7/var/log/php-fpm.log): Permission denied (13)
+$ sudo /usr/local/webserver/php7/sbin/php-fpm
+[23-Jun-2015 15:33:01] WARNING: Nothing matches the include pattern '/usr/local/webserver/php7/etc/php-fpm.d/*.conf' from /usr/local/webserver/php7/etc/php-fpm.conf at line 125.
+[23-Jun-2015 15:33:01] ERROR: failed to open error_log (/usr/local/webserver/php7/var/log/php-fpm.log): Permission denied (13)
[23-Jun-2015 15:33:01] ERROR: failed to post process the configuration
[23-Jun-2015 15:33:01] ERROR: FPM initialization failed
```
-提示错误说/usr/local/php7/var/log/php-fpm.log 没权限,就给777权限:
-$ chmod 777 /usr/local/php7/var/log/
+提示错误说/usr/local/webserver/php7/var/log/php-fpm.log 没权限,就给777权限:
+$ chmod 777 /usr/local/webserver/php7/var/log/
-修改 php-fpm 配置文件:
-$ cd /usr/local/php7/etc/
-$ cp php-fpm.conf.default php-fpm.conf
+FPM配置文件:
+复制一份
+$ cd /usr/local/webserver/php7/etc/
+$ sudo cp php-fpm.conf.default php-fpm.conf
$ vim php-fpm.conf
> 打开 error_log这一行的注释,默认该项被注释掉,若不修改会出现提示log文件路径不存在
- > error_log = /usr/local/php7/var/log/php-fpm.log
- > 打开inclue这一行的注释
- > include=/usr/local/php7/etc/php-fpm.d/*.conf
-
-修改 /usr/local/php7/etc/php-fpm.d/www.conf 文件:
+ > error_log = log/php-fpm.log
+ > 可以写成绝对路径
+ > error_log = /usr/local/webserver/php7/var/log/php-fpm.log
+ > 查看最后一行:这一行用来加载php-fpm.d目录下的配置文件
+ > 如果这一行被注释掉了,则需要打开注释(本次实验这行是打开注释的)
+ > include=/usr/local/webserver/php7/etc/php-fpm.d/*.conf
+
+修改 /usr/local/webserver/php7/etc/php-fpm.d/www.conf 文件:
如果这个文件不存在,就从default复制一份:
-$ cd /usr/local/php7/etc/php-fpm.d/
-$ cp www.conf.default www.conf
+$ cd /usr/local/webserver/php7/etc/php-fpm.d/
+$ sudo cp www.conf.default www.conf
将配置文件中的 user 和 group 部分的 nobody 改成 www:
-$ vim /usr/local/php7/etc/php-fpm.d/www.conf
+$ sudo vim /usr/local/webserver/php7/etc/php-fpm.d/www.conf
+ > 修改内容:
> user = www
- > group = www
+ > group = www
+ >
+ > 修改监听端口:默认9000端口,可以按需修改成别的,比如改成9001:
+ > listen = 127.0.0.1:9000 改成 listen = 127.0.0.1:9001
+ >
+ > 注意: 如果此处修改了FPM端口号,Nginx也要相应的修改:
+ > Nginx配置文件: /usr/local/webserver/nginx/nginc.conf
+ > fastcgi_pass 127.0.0.1:9001;
+
+检测配置文件:(检测正常)
+$ sudo /usr/local/webserver/php7/sbin/php-fpm -t
+Password:
+[22-May-2016 20:28:33] NOTICE: configuration file /usr/local/webserver/php7/etc/php-fpm.conf test is successful
+
+启动FPM:
+如果配置文件检测正常,则可以启动FPM:
+$ sudo /usr/local/webserver/php7/sbin/php-fpm
+
+查看FPM进程:
+$ ps -ef|grep fpm
+
+查看FPM版本
+$ /usr/local/webserver/php7/sbin/php-fpm -v
+PHP 7.0.7RC1 (fpm-fcgi) (built: May 22 2016 19:14:11)
+Copyright (c) 1997-2016 The PHP Group
+Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
+
开始启动 php-fpm:
```
-Mac-mini:php-7.0.0alpha1 WangTom$ /usr/local/php7/sbin/php-fpm
+$ /usr/local/webserver/php7/sbin/php-fpm
[23-Jun-2015 18:30:48] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[23-Jun-2015 18:30:48] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[23-Jun-2015 18:30:48] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
@@ -161,20 +286,28 @@ Mac-mini:php-7.0.0alpha1 WangTom$ /usr/local/php7/sbin/php-fpm
```
这个错误问题有两个:(1)没有使用root账户执行启动命令 (2)端口9000被占用
解决方法:
-使用root账户执行php-fpm启动,或 sudo /usr/local/php7/sbin/php-fpm
+使用root账户执行php-fpm启动,或 sudo /usr/local/webserver/php7/sbin/php-fpm
关闭 PHP-fpm, 并重新启动:
```
-Mac-mini:~ WangTom$ lsof -P | grep ':9000' | awk '{print $2}' | xargs kill -9
-Mac-mini:php-7.0.0alpha1 WangTom$ /usr/local/php7/sbin/php-fpm -t
-[23-Jun-2015 18:30:25] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful
-Mac-mini:~ WangTom$ sudo /usr/local/php7/sbin/php-fpm
-Mac-mini:~ WangTom$
+$ lsof -P | grep ':9000' | awk '{print $2}' | xargs kill -9
+$ /usr/local/webserver/php7/sbin/php-fpm -t
+[23-Jun-2015 18:30:25] NOTICE: configuration file /usr/local/webserver/php7/etc/php-fpm.conf test is successful
+$ sudo /usr/local/webserver/php7/sbin/php-fpm
+$
```
-修改Nginx 配置:
+## 修改Nginx 配置:
+
+注意本示例中Nginx安装路径有修改,与默认的安装的路径可能不同:
+> 修改后的具体路径如下
+> prefix=/usr/local/webserver/nginx
+> sbin-path=/usr/local/webserver/nginx/nginx
+> conf-path=/usr/local/webserver/nginx/nginx.conf
+> pid-path=/usr/local/webserver/nginx/nginx.pid
+
在 nginx.conf 配置文件server 部分增加fastcgi配置,并重新加载配置文件:
```
-Mac-mini:~ WangTom$ sudo vim /usr/local/nginx/conf/nginx.conf
+$ sudo vim /usr/local/webserver/nginx/nginx.conf
> location ~ \.php$ {
> root html;
@@ -184,13 +317,32 @@ Mac-mini:~ WangTom$ sudo vim /usr/local/nginx/conf/nginx.conf
> include fastcgi_params;
> }
-Mac-mini:~ WangTom$ sudo /usr/local/nginx/sbin/nginx -t
-nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
-nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
-Mac-mini:~ WangTom$ sudo /usr/local/nginx/sbin/nginx -s reload
-Mac-mini:~ WangTom$
+$ sudo /usr/local/webserver/nginx/nginx -t
+nginx: the configuration file /usr/local/webserver/nginx/nginx.conf syntax is ok
+nginx: configuration file /usr/local/webserver/nginx/nginx.conf test is successful
+$ sudo /usr/local/webserver/nginx/nginx -s reload
```
+
+错误:Primary script unknown
+页面打开直接显示"File not found."
+打开Nginx的error.log看到报错"Primary script unknown":
+```
+$ tail /usr/local/webserver/nginx/logs/error.log
+2016/05/22 21:17:42 [error] 24165#0: *54
+FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,
+client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1",
+upstream: "fastcgi://127.0.0.1:9001", host: "localhost"
+```
+原因:
+直接修改Nginx默认的配置,脚本路径不对。
+
+> //Nginx默认的:
+> fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+> //自己修改后的:
+> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+
用到的一些命令:
uname: 用来获取电脑和操作系统的相关信息
@@ -199,10 +351,13 @@ lsof: 列出当前系统打开文件(list open files)
which: 指令会在环境变量$PATH设置的目录里查找符合条件的文件
-参考链接:
+## 参考链接:
- http://php.net/archive/2015.php#id2015-06-11-3
- http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
+## 更新记录
+20150521 更新PHP版本到php-7.0.7RC1.
+
[END]
diff --git "a/chapter1_basic/RegularExpression-\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md" "b/chapter1_basic/RegularExpression-\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md"
new file mode 100644
index 0000000..5e75cce
--- /dev/null
+++ "b/chapter1_basic/RegularExpression-\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md"
@@ -0,0 +1,22 @@
+正则表达式(regular expression)
+
+
+ - PCRE : Regular Expressions (Perl-Compatible)
+ - Regular Expression (POSIX Extended) (DEPRECATED in PHP 5.3.0, REMOVED in PHP 7.0.0)
+
+
+
+
+
+PCRE Functions
+
+preg_filter — Perform a regular expression search and replace
+preg_grep — Return array entries that match the pattern
+preg_last_error — Returns the error code of the last PCRE regex execution
+preg_match_all — Perform a global regular expression match
+preg_match — Perform a regular expression match
+preg_quote — Quote regular expression characters
+preg_replace_callback_array — Perform a regular expression search and replace using callbacks
+preg_replace_callback — Perform a regular expression search and replace using a callback
+preg_replace — Perform a regular expression search and replace
+preg_split — Split string by a regular expression
\ No newline at end of file
diff --git a/chapter1_basic/install_php_5.4_and_phpredis.md b/chapter1_basic/install_php_5.4_and_phpredis.md
new file mode 100644
index 0000000..d8ff1a4
--- /dev/null
+++ b/chapter1_basic/install_php_5.4_and_phpredis.md
@@ -0,0 +1,431 @@
+install_php_5.4.md
+
+安装php-5.4.44环境
+
+由于某些原因,需要安装php5.4以及phpredis扩展,现记录如下。
+
+
+从PHP 5.4.0起, CLI SAPI 提供了一个内置的Web服务器。
+
+> 说明:
+> 安装目录: /usr/local/webserver/
+> 源码文件:
+> - php-5.4.44.tar.bz2
+> - phpredis-2.2.7.tar.gz
+> 主要操作: 安装PHP, 配置FPM与NGINX, 安装phpredis扩展
+
+## 环境准备:
+
+1 操作系统信息:
+
+```
+$ sw_vers
+ProductName: Mac OS X
+ProductVersion: 10.11.3
+BuildVersion: 15D21
+$ uname -mnprs
+Darwin MacWangYongTao.local 15.3.0 x86_64 i386
+```
+
+2 确保已经安装好了nginx,本机已安装了nginx/1.8.1:
+
+```
+$ /usr/local/webserver/nginx/nginx -v
+nginx version: nginx/1.8.1
+```
+
+## 安装PHP5.4
+
+网址: http://cn2.php.net/downloads.php
+下载: php-5.4.44.tar.bz2
+
+安顺序执行以下命令:
+
+```
+$ tar jxf php-5.4.44.tar.bz2
+$ cd php-5.4.44
+$ ./configure \
+ --prefix=/usr/local/webserver/php54 \
+ --with-config-file-path=/usr/local/webserver/php54 \
+ --with-mysql \
+ --with-mysqli \
+ --enable-pdo \
+ --with-pdo-mysql \
+ --with-mysql-sock=/usr/local/mysql/data/MacWang.local.pid \
+ --enable-cgi \
+ --enable-fpm \
+ --enable-sockets \
+ --enable-mbstring \
+ --enable-mbregex \
+ --enable-bcmath \
+ --enable-xml \
+ --enable-zip \
+ --with-zlib=/usr/local/lib/zlib \
+ --with-gd \
+ --with-png-dir=/usr/local/lib/libpng \
+ --with-jpeg-dir=/usr/local/lib/libjpeg \
+ --with-openssl=/usr/local/opt/openssl \
+ --with-curl=/usr/local/curl \
+ --with-mhash=/usr/local/lib/libmhash \
+ --with-mcrypt=/usr/local/lib/libmcrypt \
+$ make
+$ make test
+$ sudo make install
+```
+
+以下是安装成功后的一些信息:
+
+```
+// 代码实例:
+WangTom$ sudo make install
+Password:
+Installing PHP CLI binary: /usr/local/webserver/php54/bin/
+Installing PHP CLI man page: /usr/local/webserver/php54/php/man/man1/
+Installing PHP FPM binary: /usr/local/webserver/php54/sbin/
+Installing PHP FPM config: /usr/local/webserver/php54/etc/
+Installing PHP FPM man page: /usr/local/webserver/php54/php/man/man8/
+Installing PHP FPM status page: /usr/local/webserver/php54/php/fpm/
+Installing PHP CGI binary: /usr/local/webserver/php54/bin/
+Installing PHP CGI man page: /usr/local/webserver/php54/php/man/man1/
+Installing build environment: /usr/local/webserver/php54/lib/php/build/
+Installing header files: /usr/local/webserver/php54/include/php/
+Installing helper programs: /usr/local/webserver/php54/bin/
+ program: phpize
+ program: php-config
+Installing man pages: /usr/local/webserver/php54/php/man/man1/
+ page: phpize.1
+ page: php-config.1
+Installing PEAR environment: /usr/local/webserver/php54/lib/php/
+[PEAR] Archive_Tar - installed: 1.3.12
+[PEAR] Console_Getopt - installed: 1.3.1
+[PEAR] Structures_Graph- installed: 1.0.4
+[PEAR] XML_Util - installed: 1.2.3
+[PEAR] PEAR - installed: 1.9.5
+Wrote PEAR system config file at: /usr/local/webserver/php54/etc/pear.conf
+You may want to add: /usr/local/webserver/php54/lib/php to your php.ini include_path
+/data/softwares/php-5.4.44/build/shtool install -c ext/phar/phar.phar /usr/local/webserver/php54/bin
+ln -s -f /usr/local/webserver/php54/bin/phar.phar /usr/local/webserver/php54/bin/phar
+Installing PDO headers: /usr/local/webserver/php54/include/php/ext/pdo/
+
+$ sudo /data/softwares/php-5.4.44/build/shtool install -c ext/phar/phar.phar /usr/local/webserver/php54/bin
+$ sudo ln -s -f /usr/local/webserver/php54/bin/phar.phar /usr/local/webserver/php54/bin/phar
+```
+
+通过命令行,查看版本:
+```
+$ /usr/local/webserver/php54/bin/php -v
+PHP 5.4.44 (cli) (built: May 18 2016 19:17:07)
+```
+
+注意事项:
+
+--enable-fastcgi(已废弃)
+如果启用,CGI 模块将被编译为支持 FastCGI。PHP 4.3.0 之后的版本有效。
+PHP 5.3.0起,此参数不再存在,并使用 --enable-cgi替代。
+
+--enable-opcache(此选项在php5.5及以后版本自带,在php5.4中使用就会报unrecognized options)
+configure: WARNING: unrecognized options: --enable-opcache
+
+--with-mysql-sock 如果没有安装mysql,这个选项可以先不加上.
+执行“ps -ef |grep mysql”命令,可以看到msyql pid的路径:“pid-file=/usr/local/mysql/data/MacWang.local.pid”
+
+
+## 配置FPM:
+
+FastCGI进程管理器(FPM),编译 PHP 时需要 --enable-fpm 配置选项来激活 FPM 支持。此选项在本次在编译时已经加上了。
+
+进入php54/etc/目录,复制一份配置:php-fpm.conf
+$ cd /usr/local/webserver/php54/etc/
+$ sudo cp php-fpm.conf.default php-fpm.conf
+
+测试FPM的配置文件是否正确
+$ sudo /usr/local/webserver/php54/sbin/php-fpm -t
+
+启动 php-fpm:
+$ sudo /usr/local/webserver/php54/sbin/php-fpm
+
+
+操作实例:
+```
+//可以使用参数-t测试FPM的配置(没有复制配置文件php-fpm.conf):
+$ /usr/local/webserver/php54/sbin/php-fpm -t
+[19-May-2016 10:38:42] ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
+[19-May-2016 10:38:42] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
+[19-May-2016 10:38:42] ERROR: FPM initialization failed
+
+//可以使用参数-y指定本次安装的php54的路径
+$ /usr/local/webserver/php54/sbin/php-fpm -t -y /usr/local/webserver/php54/etc/php-fpm.conf
+[19-May-2016 10:40:55] ERROR: failed to open error_log (/usr/local/php/var/log/php-fpm.log): Permission denied (13)
+[19-May-2016 10:40:55] ERROR: failed to post process the configuration
+[19-May-2016 10:40:55] ERROR: FPM initialization failed
+
+// 如果没有权限,请使用 sudo 或者给php-fpm.log权限:
+$ /usr/local/webserver/php54/sbin/php-fpm -t
+[20-May-2016 10:29:08] ERROR: failed to open error_log (/usr/local/webserver/php54/var/log/php-fpm.log): Permission denied (13)
+[20-May-2016 10:29:08] ERROR: failed to post process the configuration
+[20-May-2016 10:29:08] ERROR: FPM initialization failed
+$ sudo /usr/local/webserver/php54/sbin/php-fpm -t
+[20-May-2016 10:32:33] NOTICE: configuration file /usr/local/webserver/php54/etc/php-fpm.conf test is successful
+
+// 如果php-fpm.log文件不存在,可以进入日志目录,创建一个日志文件,并给权限
+$ cd /usr/local/webserver/php54/var/log
+$ sudo touch php-fpm.log
+$ sudo chmod 777 php-fpm.log
+
+//可以修改FPM配置文件中的日志路径及监听端口:
+$ sudo vi /usr/local/webserver/php54/etc/php-fpm.conf
+
+> 修改FPM配置文件:(注释使用英文分号)
+> 配置文件路径: /usr/local/webserver/php54/etc/php-fpm.conf
+> //20160519
+> ;//error_log = log/php-fpm.log (默认的地址)
+> error_log = /usr/local/webserver/php54/var/log/php-fpm.log
+>
+> // 比如可以将9000端口改成9001:
+> ;listen = 127.0.0.1:9000
+> listen = 127.0.0.1:9001
+>
+> 注意: 如果此处修改了FPM端口号,Nginx也要相应的修改:
+> Nginx配置文件: /usr/local/webserver/nginx/nginc.conf
+> fastcgi_pass 127.0.0.1:9001;
+
+//出现的错误:报监听端口(127.0.0.1:9000)已经存在,是刚刚启动的,直接kill-9掉
+$ sudo /usr/local/webserver/php54/sbin/php-fpm -y /usr/local/webserver/php54/etc/php-fpm.conf -R
+[19-May-2016 10:56:03] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
+[19-May-2016 10:56:03] ERROR: FPM initialization failed
+$ ps -ef |grep fpm
+$ kill -9 11668 (这pid根据实际情况定)
+
+//重新启动,没有报错,OK
+$ sudo /usr/local/webserver/php54/sbin/php-fpm -y /usr/local/webserver/php54/etc/php-fpm.conf -R
+
+```
+
+查看版本
+```
+$ /usr/local/webserver/php54/sbin/php-fpm -v
+PHP 5.4.44 (fpm-fcgi) (built: May 18 2016 19:17:13)
+```
+
+安装完成后,如果发现/usr/local/webserver/php54/下没有PHP.ini配置文件,
+就需要手动从源码中负责一份:
+$ locate php.ini-development
+$ sudo cp /data/softwares/php-5.4.44/php.ini-development /usr/local/webserver/php54/php.ini
+
+> 在phpinfo()页面中的部分信息:
+> Server API: FPM/FastCGI
+> Virtual Directory Support: disabled
+> Configuration File (php.ini) Path: /usr/local/webserver/php54
+> Loaded Configuration File: (none)
+> Scan this dir for additional .ini files: (none)
+> Additional .ini files parsed: (none)
+
+看到 Loaded Configuration File 这一栏,信息是(none)
+
+尝试修改了一个参数,重启Nginx,发现没有变化,肯定是php.ini没有生效。
+
+但是,使用命令行,可以看到 Loaded Configuration File 的路径:
+
+```
+$ /usr/local/webserver/php54/bin/php -i | grep "php.ini"
+Configuration File (php.ini) Path => /usr/local/webserver/php54
+Loaded Configuration File => /usr/local/webserver/php54/php.ini
+
+$ /usr/local/webserver/php54/sbin/php-fpm -i |grep "php.ini"
+Configuration File (php.ini) Path => /usr/local/webserver/php54
+Loaded Configuration File => /usr/local/webserver/php54/php.ini
+```
+
+直接kill掉fpm进程,重新启动php-fpm,终于生效了:
+
+可以看到:
+Loaded Configuration File /usr/local/webserver/php54/php.ini
+
+错误:ERROR: [pool wwwuser] cannot get uid for user 'wwwuser'
+描述:修改php-fpm.conf,将配置文件中的 user 和 group 部分的 nobody 改成 www
+$ sudo /usr/local/webserver/php54/sbin/php-fpm
+[23-May-2016 16:09:59] ERROR: [pool wwwuser] cannot get uid for user 'wwwuser'
+[23-May-2016 16:09:59] ERROR: FPM initialization failed
+原因:此用户名不能随便改,需要改成系统存在的用户或者新建的用户,比如"www"
+解决:修改php-fpm.conf,将配置文件中的 user 和 group 的内容,从"wwwuser"再改成"www"
+
+错误: fopen(43): failed to open stream: Permission denied
+描述: 在代码中打开文件,写入日志,报错""
+给目录777权限都不可以
+var_dump(is_writable($filepath)); //输出false
+
+echo getcwd(); //输出的是 "nobody"
+修改php-fpm.conf配置文件,将配置文件中的 user 和 group 部分的 nobody 改成 www:
+echo getcwd(); //输出的是 "_www"
+
+
+错误新:ERROR: [pool wwwroot] cannot get uid for user 'wwwroot'
+$ sudo /usr/local/webserver/php54/sbin/php-fpm
+[23-May-2016 16:09:59] ERROR: [pool wwwroot] cannot get uid for user 'wwwroot'
+[23-May-2016 16:09:59] ERROR: FPM initialization failed
+原因:此用户名不能随便改,需要改成系统存在的用户或者新建的用户,比如"www"
+
+Mac下查看所有用户和组
+dscacheutil -q group
+$ cat /etc/group
+
+
+## Nginx配置
+
+修改nginx配置文件,使其能和php相互工作。
+
+/usr/local/webserver/nginx/nginx.conf
+
+```
+//在nginx.conf中server{}中,增加以下代码:
+location ~ \.php$ {
+ root /usr/local/webserver/nginx/html;
+ fastcgi_pass 127.0.0.1:9001;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ include fastcgi_params;
+}
+```
+
+
+通过浏览器,查看phpinfo信息:
+
+在nginx/html/目录下,放置了一个phpinfo.php文件,内容如下:
+
+> 文件phpinfo.php中的内容:
+> date_default_timezone_set("PRC");
+> phpinfo();
+
+```
+$ pwd
+/usr/local/webserver/nginx/html
+$ cat phpinfo.php
+< ? php
+date_default_timezone_set("PRC");
+phpinfo();
+```
+
+打开浏览器,输入 http://localhost/phpinfo.php,即可看到相关新。
+
+
+问题描述: 无论是在phpinfo.php页面中,还是命令行中,都可能会看到这个警告:
+```
+PHP Warning:
+Unknown: It is not safe to rely on the system's timezone settings.
+You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
+In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
+We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0.
+```
+
+问题分析:
+ 这是PHP5.4的新特性:
+ 必须使用 date.timezone php.ini 配置选项或 date_default_timezone_set() 函数来指定时区。
+ PHP 将不再尝试猜测时区,而是回退到“UTC”并发出一条 E_WARNING 错误。
+
+处理办法:
+ 在php.ini中配置时区即可:
+ > 打开date.timezone前的分号注释,写上时区,比如"Asia/Shanghai":
+ > date.timezone = Asia/Shanghai
+
+
+## 安装PhpRedis扩展
+
+
+PhpRedis, 是用C语言编写的PHP模块,用来连接并操作Redis数据库。
+
+The phpredis extension provides an API for communicating with the Redis key-value store.
+
+网址: https://github.com/phpredis/phpredis
+代码:https://github.com/phpredis/phpredis/releases
+本次下载的版本: phpredis-2.2.7.tar.gz
+
+
+$ tar zxvf phpredis-2.2.7.tar.gz
+$ cd phpredis-2.2.7
+$ /usr/local/webserver/php54/bin/phpize
+
+```
+//遇到错误,找不到autoconf,使用brew安装一下:
+$ /usr/local/webserver/php54/bin/phpize
+Configuring for:
+PHP Api Version: 20100412
+Zend Module Api No: 20100525
+Zend Extension Api No: 220100525
+Cannot find autoconf. Please check your autoconf installation and the
+$PHP_AUTOCONF environment variable. Then, rerun this script.
+
+//使用brew安装autoconf:
+$ brew install autoconf
+```
+
+
+```
+$ /usr/local/webserver/php54/bin/phpize
+Configuring for:
+PHP Api Version: 20100412
+Zend Module Api No: 20100525
+Zend Extension Api No: 220100525
+```
+
+指定php配置文件路径
+
+$ ./configure --with-php-config=//usr/local/webserver/php54//bin/php-config
+$ make
+$ make test
+$ sudo make install
+
+
+```
+//安装成功后,出现扩展的路径:
+$ sudo make install
+Password:
+Installing shared extensions:/usr/local/webserver/php54/lib/php/extensions/no-debug-non-zts-20100525/
+```
+
+注意redis.so扩展的路径:
+
+/usr/local/webserver/php54/lib/php/extensions/no-debug-non-zts-20100525/
+
+
+修改php.ini配置文件,指定redis.so文件路径:
+
+> 如果不写绝对地址,需要做个软连接,否则可能会出错:
+> extension=redis.so
+> 或者:
+> extension=/usr/local/webserver/php54/lib/php/extensions/no-debug-non-zts-20100525/redis.so
+
+注意:如果不想写全路径,可以执行以下命令,做个软连接:
+
+ln -s /usr/local/webserver/php54/lib/php/extensions/no-debug-non-zts-20100525/redis.so redis.so
+
+浏览器输入: http://localhost/phpinfo.php
+即可查看到已经安装了redis扩展了。
+
+
+查看已安装扩展(命令行):
+
+```
+// 可以使用 -m 参数来列出所有有效的扩展
+$ /usr/local/webserver/php54/bin/php -m |grep redis
+redis
+```
+
+
+## 参考链接:
+
+http://php.net/downloads.php
+https://github.com/phpredis/phpredis#classes-and-methods
+https://github.com/phpredis/phpredis/issues/468
+http://php.net/manual/zh/migration54.incompatible.php
+
+
+## 更新记录:
+
+2016-05-18: 新增安装php5.4.44环境
+2016-05-19: 新增安装phpredis扩展
+
+
+[END]
+
+
+
diff --git "a/chapter1_basic/\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md" "b/chapter1_basic/\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md"
deleted file mode 100644
index 5d77f55..0000000
--- "a/chapter1_basic/\345\256\211\350\243\205Nginx\346\234\215\345\212\241\345\231\250.md"
+++ /dev/null
@@ -1,93 +0,0 @@
-02-如何源码安装Nginx服务器
-
-# 02-如何源码安装Nginx服务器
-
-##### 安装 PCRE :
-> 网站:http://pcre.org/
-> 下载:
-> - ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
-> - ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.bz2
-
-##### 安装 Nginx :
-> + 网站地址:http://nginx.org/en/docs/
-> + 下载地址:http://nginx.org/download/nginx-1.8.0.tar.gz
-
-##### 安装命令:
-```
-下载:
-wget http://nginx.org/download/nginx-1.8.0.tar.gz
-
-tar zxf nginx-1.8.0.tar.gz
-cd nginx-1.8.0
-./configure --prefix=/usr/local/nginx
-make
-sudo make install
-
-./configure --prefix=/usr/local/nginx \
- --sbin-path=/usr/local/nginx/nginx \
- --conf-path=/usr/local/nginx/nginx.conf \
- --pid-path=/usr/local/nginx/nginx.pid \
- --with-http_ssl_module \
-
-
-
-
-ps -ef |grep nginx
-
-启动Nginx:
-sudo /usr/local/nginx/sbin/nginx
-
-重新加载配置文件:
-sudo /usr/local/nginx/sbin/nginx -t
-sudo /usr/local/nginx/sbin/nginx -s reload
-
-```
-
-##### 检查是否安装成功:
-
-[1] 命令行查看Nginx版本:
-```
-/usr/local/nginx/sbin/nginx -V
-Mac-mini:nginx-1.8.0 WangTom$ /usr/local/nginx/sbin/nginx -V
-nginx version: nginx/1.8.0
-built by clang 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
-configure arguments: --prefix=/usr/local/nginx
-
-Mac-mini:nginx-1.8.0 WangTom$ /usr/local/nginx/sbin/nginx -v
-nginx version: nginx/1.8.0
-```
-
-[2] 浏览器中查看页面
-在浏览器中访问: http://localhost/ 安装成功则页面出现:
-```
-Welcome to nginx!
-If you see this page, the nginx web server is successfully installed and working.
-Further configuration is required.
-For online documentation and support please refer to nginx.org.
-Commercial support is available at nginx.com.
-Thank you for using nginx.
-```
-查看 Nginx 版本:
-Mac-mini:html WangTom$ sudo /usr/local/nginx/sbin/nginx -v
-nginx version: nginx/1.8.0
-
-检测 Nginx 配置文件
-Mac-mini:html WangTom$ sudo /usr/local/nginx/sbin/nginx -t
-nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
-nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
-
-
-To apply the new configuration, start nginx if it is not yet started or send the reload signal to the nginx’s master process, by executing:
-Mac-mini:html WangTom$ sudo /usr/local/nginx/sbin/nginx -s reload
-Mac-mini:html WangTom$
-
-
-
-##### 参考地址:
-
-Building nginx from Sources:
-http://nginx.org/en/docs/configure.html
-
-
-
-[END]
diff --git "a/chapter1_basic/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md" "b/chapter1_basic/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217.md"
deleted file mode 100644
index e69de29..0000000
diff --git "a/chapter2_php/PHP\344\270\216\346\225\260\346\215\256\345\272\223.md" "b/chapter2_php/PHP\344\270\216\346\225\260\346\215\256\345\272\223.md"
deleted file mode 100644
index 58329fc..0000000
--- "a/chapter2_php/PHP\344\270\216\346\225\260\346\215\256\345\272\223.md"
+++ /dev/null
@@ -1,18 +0,0 @@
-
-# PHP与数据库
-
-关系型数据库MySQL
-
-
-NoSQL数据库
-
-键值存储型数据库Memcache
-
-支持数据结构特性的Redis
-
-
-
-
-
-
-
diff --git "a/chapter2_php/PHP\345\255\227\347\254\246\344\270\262.md" "b/chapter2_php/PHP\345\255\227\347\254\246\344\270\262.md"
deleted file mode 100644
index e727b53..0000000
--- "a/chapter2_php/PHP\345\255\227\347\254\246\344\270\262.md"
+++ /dev/null
@@ -1,19 +0,0 @@
-PHP学习参考指南
-
-Chapter-01 PHP是什么?
-
-- PHP是神马东东?
-PHP(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发。
-
-- PHP能干什么?
-
-使用 PHP 的一大好处是它对于初学者来说极其简单。
-
-PHP 主要是用于服务端的脚本程序。
-
-
-
-
-
-
-
diff --git "a/chapter2_php/PHP\346\225\260\347\273\204.md" "b/chapter2_php/PHP\346\225\260\347\273\204.md"
deleted file mode 100644
index e727b53..0000000
--- "a/chapter2_php/PHP\346\225\260\347\273\204.md"
+++ /dev/null
@@ -1,19 +0,0 @@
-PHP学习参考指南
-
-Chapter-01 PHP是什么?
-
-- PHP是神马东东?
-PHP(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发。
-
-- PHP能干什么?
-
-使用 PHP 的一大好处是它对于初学者来说极其简单。
-
-PHP 主要是用于服务端的脚本程序。
-
-
-
-
-
-
-
diff --git "a/chapter2_php/PHP\346\226\207\344\273\266\347\256\241\347\220\206.md" "b/chapter2_php/PHP\346\226\207\344\273\266\347\256\241\347\220\206.md"
deleted file mode 100644
index 36246c8..0000000
--- "a/chapter2_php/PHP\346\226\207\344\273\266\347\256\241\347\220\206.md"
+++ /dev/null
@@ -1,20 +0,0 @@
-# PHP文件系统
-
-文件和文件系统
-
-文本文件和二进制文件
-
-文件的打开方式
-
-文件的顺序存取和随机存取
-
-XML和JSON操作要点
-
-文件的存储和磁盘阵列
-
-大文件上传和断点续传
-
-
-
-
-
diff --git "a/chapter2_php/PHP\347\256\200\344\273\213.md" "b/chapter2_php/PHP\347\256\200\344\273\213.md"
deleted file mode 100644
index e727b53..0000000
--- "a/chapter2_php/PHP\347\256\200\344\273\213.md"
+++ /dev/null
@@ -1,19 +0,0 @@
-PHP学习参考指南
-
-Chapter-01 PHP是什么?
-
-- PHP是神马东东?
-PHP(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发。
-
-- PHP能干什么?
-
-使用 PHP 的一大好处是它对于初学者来说极其简单。
-
-PHP 主要是用于服务端的脚本程序。
-
-
-
-
-
-
-
diff --git a/chapter2_php/README.md b/chapter2_php/README.md
deleted file mode 100644
index 6ad8faa..0000000
--- a/chapter2_php/README.md
+++ /dev/null
@@ -1,93 +0,0 @@
-chapter2/README.md
-
-
-# PHP选项和运行原理
-
-PHP运行模式
-
-PHP的Thread Safe和Non Thread Safe
-
-CGI、FastCGI、 ISAPI、SAPI
-
-Apache下的work和prefork模式
-
-Nginx下PHP的FastCGI模式
-
-比较I/O模型select和epoll
-
-PHP的运行机制与原理
-
-PHP的垃圾回收机制
-
-PHP选项相关的问题
-
-
-
-
-# PHP数据结构
-
-数据结构基本概念
-
-算法和算法的时间复杂度
-
-常见结构:链表、线性表、 队列和堆栈
-
-递归和循环的相互转化
-
-PHP查找和排序算法详解
-
-分解法和“剥洋葱”法的算法设计技巧
-
-
-# PHP高级特性
-
-PHP的Callback函数
-
-PHP的魔术方法
-
-自动加载对象的应用
-
-PHP的反射机制
-
-PHP的异常处理
-
-
-# PHP设计模式
-
-设计模式简介
-
-工厂模式详解
-
-策略模式详解
-
-观察者模式详解
-
-装饰模式详解
-
-单例模式详解
-
-适配器模式详解
-
-设计模式综合应用
-
-
-# PHP开发框架
-
-
-# PHP安全
-
-WEB安全入门
-
-常用测试漏洞工具
-
-点击劫持与任意重定向漏洞
-
-XSS与CSRF漏洞详解
-
-注入漏洞原理分析
-
-访问控制与命令执行漏洞
-
-文件上传下载与敏感信息泄露漏洞
-
-各种漏洞修复和防范技巧
\ No newline at end of file
diff --git "a/chapter3_javascript/JavaScript-\345\237\272\347\241\200.md" "b/chapter3_javascript/JavaScript-\345\237\272\347\241\200.md"
new file mode 100644
index 0000000..c70f74b
--- /dev/null
+++ "b/chapter3_javascript/JavaScript-\345\237\272\347\241\200.md"
@@ -0,0 +1,195 @@
+JavaScript基础知识.md
+
+
+JavaScript® (JS) 是一门轻量的、解释型的、将函数视为一级公民的程序设计语言。
+它是最为出名的网页脚本语言,但也在很多非网页环境中运用,例如 node.js 和 Apache CouchDB。
+它是一种基于原型的、多范式的动态脚本语言,并且支持面向对象、命令式编程风格和声明式(如:函数式编程)编程风格。
+
+JavaScript 的标准就是 ECMAScript。
+截至 2012 年为止,所有的主流浏览器都完整的支持 ECMAScript 5.1,旧式的浏览器至少支持 ECMAScript 3 标准。
+在2015年6月17日,ECMA国际组织发布了ECMAScript的第六个版本,该版本正式名称为ECMAScript 2015,但通常被称为ECMAScript 6或者ES6。
+
+JavaScript 与 Java 编程语言是两个不同的概念。虽然“Java”和“JavaScript”都是 Oracle 公司在美国和其他国家注册(或未注册)的商标,但是这两门语言在语法、语义与用途方面有很大不同。
+
+
+HTML是用来存储网页内容的,CSS是用来定义这些内容的显示样式的,而JavaScript是用来创造丰富的页面效果或者网页应用的。
+但是,如果从浏览器的范畴去理解“JavaScript”这个术语,它包含了截然不同的两个方面。
+一个是JavaScript的核心语言(ECMAScript),另一个是DOM(文档对象模型)。
+
+
+
+
+typeof, null, 和 undefined
+
+
+## typeof
+
+typeof 操作符返回一个字符串,表示未经求值的操作数(unevaluated operand)的类型。
+
+语法:typeof operand
+参数:operand 是一个表达式,表示对象或原始值,其类型被返回。
+描述E:此表总结了 typeof 可能的返回值。
+
+| 类型 | 结构 |
+| -------------------- | -------------------------- |
+| Undefined | `"undefined"` |
+| Null | `"object" `(见下方) |
+| 布尔值 | `"boolean"` |
+| 数值 | `"number"` |
+| 字符串 | `"string"` |
+| Symbol (ECMAScript 6 新增) | `"symbol"` |
+| 宿主对象(JS环境提供的,比如浏览器) | *Implementation-dependent* |
+| 函数对象 (implements [[Call]] in ECMA-262 terms) | `"function"`|
+| 任何其他对象 | `"object"`|
+
+实例:
+
+```
+typeof "John" // 返回 string
+typeof "" // 返回 string
+typeof 3.14 // 返回 number
+typeof true // 返回 boolean
+typeof false // 返回 boolean
+typeof [1,2,3,4] // 返回 object
+typeof {name:'John', age:34} // 返回 object
+```
+> Notes:
+> 在JavaScript中,数组是一种特殊的对象类型。 因此 typeof [1,2,3,4] 返回 object。
+
+
+## Null
+
+null 是一个 JavaScript 字面量,表示空值(null or an "empty" value),表示 "什么都没有"。即没有对象被呈现(no object value is present)。
+null 是一个只有一个值的特殊类型。表示一个空对象引用。它是 JavaScript 的原始值之一。
+null 是一个字面量(而不是全局对象的一个属性,undefined 是)
+
+> Note: 用 typeof 检测 null 返回是object。
+> Note: ECMAScript 有 5 种原始类型(primitive type),即 Undefined、Null、Boolean、Number 和 String。
+
+实例
+
+```
+可以设置为 null 来清空对象:
+var person = null; // Value is null, but type is still an object
+
+也可以设置为 undefined 来清空对象:
+var person = undefined; // 值为 undefined, type is undefined
+```
+
+## Undefined
+
+undefined有多重角色,通常情况下,我们所说的undefined都指的是全局对象的一个属性"undefined".
+
+在 JavaScript 中, undefined 是一个没有设置值的变量。typeof 一个没有值的变量会返回 undefined。
+
+一个未初始化的变量的值为undefined.
+一个没有传入实参的形参变量的值为undefined.
+如果一个函数什么都不返回,则该函数默认返回undefined.
+
+
+> 在JavaScript中,undefined这个词有多重含义:
+> (1) 首字母大写的Undefined表示的是一种数据类型;
+> (2) 小写的undefined表示的是属于这种数据类型的唯一的一个值;
+> 但这两种undefined都只能存在于文档或规范中,不能存在于JavaScript代码中.
+>
+> 在JavaScript代码中,我们看到的undefined最有可能是全局对象的一个属性,该属性的初始值是就是前面所说的原始值undefined.
+> 还有种情况就是,这个undefined是个局部变量,就像其他普通变量一样,没有任何特殊性,它的值不一定是undefined,但通常情况下都是的.
+>
+> 下面我们所说的undefined,都指的是window.undefined这个属性.
+
+
+
+实例:
+
+```
+var person; // Value is undefined, type is undefined
+
+可以使用严格相等运算符来判断一个值是否是undefined:
+var x;
+if ( x === undefined ) {
+ // 执行到这里
+} else {
+ // 不会执行到这里
+}
+```
+
+这里必须使用严格相等运算符===,而不能使用普通的相等运算符==.
+因为x == undefined成立还可能是因为x为null,在JavaScript中null== undefined是返回true的.
+
+另外,还可以使用typeof来判断:
+
+```
+var x;
+if (typeof x === 'undefined') {
+ // 执行到这里
+}
+```
+
+任何变量都可以通过设置值为 undefined 来清空。 类型为 undefined.
+实例
+person = undefined; // 值为 undefined, type is undefined
+
+
+## NaN 值
+
+NaN 是一个全局对象的属性,表示 Not-A-Number 的值,是一个特殊值。
+
+在编码很少直接使用到 NaN。通常都是在计算失败时,作为 Math 的某个方法的返回值出现的(例如:Math.sqrt(-1))或者尝试将一个字符串解析成数字但失败了的时候(例如:parseInt("blabla"))。
+
+
+NaN 不等于自己, 即 NaN == NaN 返回的是 false
+判断一个值是否是 NaN, 必须使用 Number.isNaN() 或 isNaN() 函数
+
+isNaN() 函数用于检查其参数是否是非数字值。
+isNaN() 函数通常用于检测 parseFloat() 和 parseInt() 的结果,以判断它们表示的是否是合法的数字。当然也可以用 isNaN() 函数来检测算数错误,比如用 0 作除数的情况。
+如果isNaN函数的参数不是Number类型, isNaN()会首先尝试将这个参数转换为数值,然后才会对转换后的结果是否是NaN进行判断。
+
+```
+isNaN(123); // 返回 false
+isNaN(-1.23); // 返回 false
+isNaN(5-2); // 返回 false
+isNaN(0); // 返回 false
+isNaN("0"); // 返回 false
+isNaN(true); // 返回 false: 因为Number(true)是1
+isNaN(false); // 返回 false: 因为Number(false)是0
+isNaN(null); // 返回 false: 因为Number(null)是0
+
+isNaN("Hello"); // 返回 true
+isNaN("2016/07/11"); // 返回 true
+isNaN(NaN); // 返回 true
+isNaN(undefined); // 返回 true
+isNaN({}); // 返回 true
+
+// dates
+isNaN(new Date()); // 返回 false
+isNaN(new Date().toString()); // 返回 true
+```
+
+
+undefined 和 Null 的区别
+
+```
+typeof undefined // 返回undefined
+typeof null // 返回object (bug in ECMAScript, should be null)
+null === undefined // 返回false
+null == undefined // 返回true
+```
+
+
+underfined和"undefined"的区别:
+
+undefined是JavaScript提供的一个"关键字",而"undefined"就是一个字符串,只是字符串的内容长得和undefined一样而已。
+
+```
+typeof undefined // 返回undefined
+typeof "undefined" // 返回string
+```
+
+
+
+参考链接:
+
+http://www.w3school.com.cn/jsref/jsref_isNaN.asp
+https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/isNaN
+https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/undefined
+
diff --git "a/chapter3_javascript/JavaScript-\345\257\271\350\261\241.md" "b/chapter3_javascript/JavaScript-\345\257\271\350\261\241.md"
new file mode 100644
index 0000000..5db0036
--- /dev/null
+++ "b/chapter3_javascript/JavaScript-\345\257\271\350\261\241.md"
@@ -0,0 +1,22 @@
+JavaScript对象.md
+
+JavaScript 对象
+JS Array
+JS Boolean
+JS Date
+JS Math
+JS Number
+JS String
+JS RegExp
+JS Functions
+JS Events
+
+
+
+
+
+
+参考资料:
+
+http://www.w3school.com.cn/js/js_objects.asp
+
diff --git a/chapter3_js_html/README.md b/chapter3_javascript/README.md
similarity index 62%
rename from chapter3_js_html/README.md
rename to chapter3_javascript/README.md
index 1e32da8..71d620a 100644
--- a/chapter3_js_html/README.md
+++ b/chapter3_javascript/README.md
@@ -22,3 +22,15 @@ Ajax技术和跨域问题
编写jQuery插件
+
+
+参考链接:
+
+https://developer.mozilla.org/zh-CN/docs/Web/JavaScript
+
+http://www.w3school.com.cn/js/index.asp
+
+http://www.runoob.com/js/js-tutorial.html
+
+
+
diff --git a/chapter4_database/MySQL-Quick-Start.md b/chapter4_database/MySQL-Quick-Start.md
new file mode 100644
index 0000000..9f491a4
--- /dev/null
+++ b/chapter4_database/MySQL-Quick-Start.md
@@ -0,0 +1,42 @@
+MySQL-Quick-Start.md
+
+MySQL是一个关系型数据库管理系统,由瑞典 MySQL AB 公司1995年发布,2008年被 Sun Microsystems 公司收购,2010年,Oracle 收购 Sun Microsystems, 目前属于Oracle公司。
+
+
+$ mysql -u root -p
+
+
+
+# 修改表结构:
+
+## 新增表字段:
+
+```
+ALTER TABLE `test_invoice`
+ADD COLUMN `taxpayer_name` varchar(50) NOT NULL DEFAULT '' COMMENT '纳税人名称',
+ADD COLUMN `taxpayer_id` varchar(50) NOT NULL DEFAULT '' COMMENT '纳税人识别号',
+```
+
+## 修改表字段:
+
+```
+ALTER TABLE `test_invoice`
+CHANGE COLUMN `type` `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '类型:1-类型1,2-类型2';
+```
+
+# mysqldump
+
+
+* 导出全部数据库及表
+$ mysqldump -u root -p homestead > mysql_backup_201706.sql
+
+
+* 导出部分数据库及表
+$ mysqldump --databases db1 db2 db3 > /tmp/dump.sql
+
+
+
+
+# Reference:
+
+https://dev.mysql.com/doc/refman/5.6/en/mysqldump.html
\ No newline at end of file
diff --git "a/chapter5_linux/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" "b/chapter5_linux/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
deleted file mode 100644
index 54b9eb9..0000000
--- "a/chapter5_linux/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
+++ /dev/null
@@ -1,184 +0,0 @@
-Git使用教程.md
-
-# Git简介
-
-Git是一个分布式的版本控制系统(DVCS, Distributed Version Control Systems).
-
-Git官网: https://git-scm.com/
-Git下载: https://git-scm.com/download/
-
-### Git常用命令
-
-git pull:取回远程主机某个分支的更新,再与本地的指定分支合并
-
-格式:git pull <远程主机名> <远程分支名>:<本地分支名>
-
-示例:
-```
-$ git pull origin dev
-From code.XXX.com:wangyt/php-dev-docs
- * branch dev -> FETCH_HEAD
-Already up-to-date.
-```
-
-
-git log
-
-查看日志:git log
-参数--pretty=online显示成一行
-> git log
-> git log --pretty=online
-
-
-
-
-mkdir git-test
-cd git-test/
-git init
-vim readme.txt
-git status
-git add readme.txt
-git commit -m 'add new file readme.txt'
-
-vim readme.txt
-git status
-git diff readme.txt
-git commit -m 'update readme.txt'
-
-git add readme.txt
-git commit -m 'update readme.txt'
-git log
-git status
-
-vim readme.txt
-git commit -m 'update readme.txt:TEST'
-git add readme.txt
-git commit -m 'update readme.txt:TEST'
-
-
-
-
-
-回到上一个版本
-git reset --hard HEAD^
-
-回到某个指定的 commit id 版本:
-git reset --hard 3628164
-
-使用 git reflog 查看命令历史
-$ git reflog
-2630090 HEAD@{0}: reset: moving to 2630090
-c585eb1 HEAD@{1}: reset: moving to HEAD^
-2630090 HEAD@{2}: commit: update readme.txt:TEST
-c585eb1 HEAD@{3}: commit: update readme.txt
-6d0aee0 HEAD@{4}: commit (initial): add new file readme.txt
-
-
-```
-//编辑完文件,查看状态,会提示可能的操作
-$ git status
-On branch master
-Your branch is up-to-date with 'origin/master'.
-Changes not staged for commit:
- (use "git add ..." to update what will be committed)
- (use "git checkout -- ..." to discard changes in working directory)
- modified: git.doc.md
-no changes added to commit (use "git add" and/or "git commit -a")
-```
-
-Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master)
-$ git branch
- dev
-* master
-
-Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master)
-$ git status
-On branch master
-Your branch is up-to-date with 'origin/master'.
-Changes not staged for commit:
- (use "git add ..." to update what will be committed)
- (use "git checkout -- ..." to discard changes in working directory)
- modified: git.doc.md
-no changes added to commit (use "git add" and/or "git commit -a")
-
-Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master)
-$ git add git.doc.md
-
-Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master)
-$ git commit -m "UPDATE git.doc.md"
-[master daeebd5] UPDATE git.doc.md
- 1 file changed, 52 insertions(+), 10 deletions(-)
-
-Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master)
-$ git status
-On branch master
-Your branch is ahead of 'origin/master' by 1 commit.
- (use "git push" to publish your local commits)
-nothing to commit, working directory clean
-
-Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master)
-$ git push
-Counting objects: 3, done.
-Delta compression using up to 4 threads.
-Compressing objects: 100% (3/3), done.
-Writing objects: 100% (3/3), 1.17 KiB | 0 bytes/s, done.
-Total 3 (delta 1), reused 0 (delta 0)
-To git@code.boqii.com:wangyt/php-dev-docs
- 710954f..daeebd5 master -> master
-
-Administrator@BQ-DN-BJB-022 MINGW64 /d/working/php-dev-docs (master)
-$ git status
-On branch master
-Your branch is up-to-date with 'origin/master'.
-nothing to commit, working directory clean
-
-
-
-
-### 配置
-
-列出当前的配置:
-
-git config -l
-git config --global
-git config --local
-
-设置邮箱和用户名:
-> 如果没有配置邮箱与用户名,提交时会提示配置:
-> ```
-> $ git commit -m "Add configure.php.dev.env.md"
-> *** Please tell me who you are.
-> Run
-> git config --global user.email "you@example.com"
-> git config --global user.name "Your Name"
-> ```
-
-```
-//全局的设置
-$ git config --global user.email "ahwyt2008@foxmail.com"
-$ git config --global user.name "WangYongTao"
-```
-
-```
-//局部的设置
-$ git config --local user.email "ahwyt2008@163.com"
-$ git config --local user.name "WANGYongTao"
-```
-
-
-
-
-# Git教程
-
-官方教程:《Pro Git : 2nd Edition (2014)》
-https://git-scm.com/book/en/v2
-https://git-scm.com/book/zh (中文版)
-
-廖雪峰的官方网站:《Git教程》
-http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
-
-易佰:《Git教程》
-http://www.yiibai.com/git/
-
-
-# 参考链接
diff --git a/chapter5_linux/README.md b/chapter5_linux/README.md
deleted file mode 100644
index e7f2ae0..0000000
--- a/chapter5_linux/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-
-Linux的哲学思想
-
-常用指令和使用技巧
-
-文件权限和文件操作
-
-管道和重定向
-
-crontab和后台任务
-
-Vim编辑器使用技巧
-
-Shell程序设计
-
-
diff --git "a/chapter6_practice/Shortcut-Key-\345\277\253\346\215\267\351\224\256.md" "b/chapter6_practice/Shortcut-Key-\345\277\253\346\215\267\351\224\256.md"
new file mode 100644
index 0000000..d5babc6
--- /dev/null
+++ "b/chapter6_practice/Shortcut-Key-\345\277\253\346\215\267\351\224\256.md"
@@ -0,0 +1,32 @@
+Shortcut Key 常用快捷键
+
+### 文本编辑器 Vi
+
+
+### 终端工具 iTerm2
+
+* 分屏操作:
+ - Shift + Command + D(横向)
+ - Command + D(竖向)
+ - Command + W(关闭当前分屏窗口)
+ - Command + + 加号,放大终端字体
+ - Command + - 减号,减小终端字体
+* 查找和粘贴:
+
+ - Command + F 查找功能,tab 键选中找到的文本 Option+ENTER 粘贴
+ - Command + ; 根据上下文呼出自动完成窗口,上下键选择
+
+* 粘贴历史:
+ - Shift+Command+H
+
+* 回放功能:
+ - Option+Command+B
+
+* 全屏:
+ - Command + ENTER 全屏显示,再次操作恢复原状
+
+* 查看光标位置:
+ - Command + /
+
+* Expose Tabs:
+ - Option+Command+E
diff --git a/chapter6_practice/php.design.pattern.md b/chapter6_practice/php.design.pattern.md
new file mode 100644
index 0000000..c3cbf97
--- /dev/null
+++ b/chapter6_practice/php.design.pattern.md
@@ -0,0 +1,85 @@
+PHP Design Pattern
+
+
+
+设计模式(Design pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。
+使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可靠性。
+
+
+SOLID (object-oriented design)
+SOLID (single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion)
+
+面向对象的五大基本原则:
+
+(1) 单一职责原则(SRP, Single Responsiblity Principle)
+(2) 开放封闭原则(OCP, Open Closed Principle)
+(3) 里氏替换原则(LSP, Liskov Substitution Principle)
+(4) 接口隔离原则(ISP, Interface Segregation Principle)
+(5) 依赖倒置原则(DIP, Dependency Inversion Principle)
+
+
+面向对象有几个原则:
+
+单一职责原则 (Single Responsiblity Principle SRP)
+开闭原则(Open Closed Principle,OCP)
+里氏代换原则(Liskov Substitution Principle,LSP)
+依赖倒转原则(Dependency Inversion Principle,DIP)
+接口隔离原则(Interface Segregation Principle,ISP)
+合成/聚合复用原则(Composite/Aggregate Reuse Principle,CARP)
+最小知识原则(Principle of Least Knowledge,PLK,也叫迪米特法则)
+
+开闭原则具有理想主义的色彩,它是面向对象设计的终极目标。
+其他几条,则可以看做是开闭原则的实现方法。
+设计模式就是实现了这些原则,从而达到了代码复用、增加可维护性的目的。
+
+
+单一职责原则 (Single Responsiblity Principle SRP)
+
+单一职责原则(SRP:Single responsibility principle)又称单一功能原则,面向对象五个基本原则(SOLID)之一。
+它规定一个类应该只有一个发生变化的原因。该原则由罗伯特·C·马丁(Robert C. Martin)于《敏捷软件开发:原则、模式和实践》一书中给出的。马丁表示此原则是基于汤姆·狄马克(Tom DeMarco)和Meilir Page-Jones的著作中的内聚性原则发展出的。
+
+
+开闭原则(Open Closed Principle,OCP)
+
+此原则是由Bertrand Meyer提出的。
+原文是:“Software entities should be open for extension,but closed for modification”。
+就是说模块应对扩展开放,而对修改关闭。
+模块应尽量在不修改原(是“原”,指原来的代码)代码的情况下进行扩展。
+
+里氏代换原则(Liskov Substitution Principle,LSP)
+
+里氏代换原则是由Barbara Liskov提出的。如果调用的是父类的话,那么换成子类也完全可以运行。
+
+
+
+依赖倒转原则(Dependency Inversion Principle,DIP)
+
+指在软件里面,把父类都替换成它的子类,程序的行为没有变化。
+简单的说,子类型能够替换掉它们的父类型。
+依赖性倒转其实可以说是面向对象设计的标志,用哪种语言编程并不是很重要。
+
+
+
+接口隔离原则(Interface Segregation Principle,ISP)
+
+定制服务的例子,每一个接口应该是一种角色,不多不少,不干不该干的事,该干的事都要干。
+
+
+合成/聚合复用原则(Composite/Aggregate Reuse Principle,CARP)
+
+合成/聚合复用原则(Composite/Aggregate Reuse Principle,CARP)经常又叫做合成复用原则。
+合成/聚合复用原则就是在一个新的对象里面使用一些已有的对象,使之成为新对象的一部分;新的对象通过向这些对象的委派达到复用已有功能的目的。
+它的设计原则是:要尽量使用合成/聚合,尽量不要使用继承。
+
+
+最小知识原则(Principle of Least Knowledge,PLK,也叫迪米特法则)
+最少知识原则也叫迪米特法则。
+不要和陌生人说话,即一个对象应对其他对象有尽可能少的了解。
+
+迪米特法则(Law of Demeter)又叫作最少知识原则(Least Knowledge Principle 简写LKP),就是说一个对象应当对其他对象有尽可能少的了解,不和陌生人说话.
+
+1987年秋天由美国Northeastern University的Ian Holland提出,被UML的创始者之一Booch等普及。
+后来,因为在经典著作《 The Pragmatic Programmer》而广为人知。
+
+迪米特法则的初衷在于降低类之间的耦合。
+由于每个类尽量减少对其他类的依赖,因此,很容易使得系统的功能模块功能独立,相互之间不存在(或很少有)依赖关系。
diff --git a/elasticsearch/Elasticsearch-Quick-Start.md b/elasticsearch/Elasticsearch-Quick-Start.md
new file mode 100644
index 0000000..769d95c
--- /dev/null
+++ b/elasticsearch/Elasticsearch-Quick-Start.md
@@ -0,0 +1,401 @@
+
+Elasticsearch is a highly scalable open-source full-text search and analytics engine.
+
+Basic Concepts
+
+Near Realtime (NRT)
+
+Cluster
+
+Node
+
+Index
+
+Type
+
+Document
+
+
+Shards & Replicas
+
+
+
+安装 Elasticsearch
+
+Elasticsearch requires at least Java 8.
+Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8.0_73.
+
+$ java -version
+java version "1.8.0"
+Java(TM) SE Runtime Environment (build 1.8.0-b132)
+Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
+
+
+```
+$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.0.tar.gz
+$ tar zxf elasticsearch-5.3.0.tar.gz
+$ cd elasticsearch-5.3.0
+$ bin/elasticsearch
+
+$ curl http://localhost:9200/
+{
+ name: "xdkVW67",
+ cluster_name: "elasticsearch",
+ cluster_uuid: "To-C3m1kQpyMLX8suLxK7g",
+ version: {
+ number: "5.3.0",
+ build_hash: "3adb13b",
+ build_date: "2017-03-23T03:31:50.652Z",
+ build_snapshot: false,
+ lucene_version: "6.4.1"
+ },
+ tagline: "You Know, for Search"
+}
+```
+
+REST API
+
+Among the few things that can be done with the API are as follows:
+
+Check your cluster, node, and index health, status, and statistics
+Administer your cluster, node, and index data and metadata
+Perform CRUD (Create, Read, Update, and Delete) and search operations against your indexes
+Execute advanced search operations such as paging, sorting, filtering, scripting, aggregations, and many others
+
+* 参数 v, 可以显示结果的标题栏
+* 参数 pretty, 可以美观的形式打印出JSON响应
+* 参数 format, 可以选择响应的格式,目前支持text, yaml, json三种
+* 参数 s, 可以选择响应的格式,目前支持text, yaml, json三种
+
+```
+$ curl 'localhost:9200/_cat/master'
+xdkVW67ARQiukQf9nVY3PA 127.0.0.1 127.0.0.1 xdkVW67
+```
+
+```
+$ curl 'localhost:9200/_cat/master?v'
+id host ip node
+xdkVW67ARQiukQf9nVY3PA 127.0.0.1 127.0.0.1 xdkVW67
+```
+
+```
+// 默认: format=text
+$ curl 'localhost:9200/_cat/master?v'
+id host ip node
+xdkVW67ARQiukQf9nVY3PA 127.0.0.1 127.0.0.1 xdkVW67
+
+// format=yaml
+$ curl 'localhost:9200/_cat/master?v&format=yaml'
+---
+- id: "xdkVW67ARQiukQf9nVY3PA"
+ host: "127.0.0.1"
+ ip: "127.0.0.1"
+ node: "xdkVW67"
+
+// format=json
+$ curl 'localhost:9200/_cat/master?v&format=json'
+[{"id":"xdkVW67ARQiukQf9nVY3PA","host":"127.0.0.1","ip":"127.0.0.1","node":"xdkVW67"}]%
+
+$ curl 'localhost:9200/_cat/master?v&format=json&pretty'
+[
+ {
+ "id" : "xdkVW67ARQiukQf9nVY3PA",
+ "host" : "127.0.0.1",
+ "ip" : "127.0.0.1",
+ "node" : "xdkVW67"
+ }
+]
+```
+
+$ curl 'localhost:9200/_cat/master?help'
+id | | node id
+host | h | host name
+ip | | ip address
+node | n | node name
+
+
+For example, with a sort string s=column1,column2:desc,column3, the table will be sorted in ascending order by column1, in descending order by column2, and in ascending order by column3.
+
+
+curl 'http://localhost:9200/_cat/health?v'
+
+```
+curl 'http://localhost:9200/_cat/health?v'
+epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
+1491441171 09:12:51 elasticsearch green 1 1 0 0 0 0 0 0 - 100.0%
+```
+
+集群的名字是“elasticsearch”,状态是绿色, 正常。
+当我们询问集群状态的时候,我们要么得到绿色、黄色或红色。
+在 Elasticsearch 集群中可以监控统计很多信息,其中最重要的就是:集群健康(cluster health)。它的 status 有 green、yellow、red 三种;
+三种颜色分别代表:
+* green: 所有主分片和从分片都可用
+* yellow: 所有主分片可用,但存在不可用的从分片
+* red: 存在不可用的主要分片
+
+
+后去节集群中的节点列表:
+
+```
+curl 'http://localhost:9200/_cat/nodes?v'
+ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
+127.0.0.1 20 100 7 1.68 mdi * xdkVW67
+```
+
+
+列出所有的索引
+```
+curl 'localhost:9200/_cat/indices?v'
+health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
+```
+这个结果意味着,在我们的集群中,我们没有任何索引。
+
+现在我们创建一个叫做 "helloworld" 的索引,然后再列出所有的索引:
+
+```
+// 注意索引名称须为小写字母,否则会报错“Invalid index name [HelloWorld], must be lowercase”
+$ curl -XPUT 'localhost:9200/HelloWorld?pretty'
+{
+ "error" : {
+ "root_cause" : [
+ {
+ "type" : "invalid_index_name_exception",
+ "reason" : "Invalid index name [HelloWorld], must be lowercase",
+ "index_uuid" : "_na_",
+ "index" : "HelloWorld"
+ }
+ ],
+ "type" : "invalid_index_name_exception",
+ "reason" : "Invalid index name [HelloWorld], must be lowercase",
+ "index_uuid" : "_na_",
+ "index" : "HelloWorld"
+ },
+ "status" : 400
+}
+
+// 创建一个名为 helloworld 的索引
+$ curl -XPUT 'localhost:9200/helloworld?pretty'
+{
+ "acknowledged" : true,
+ "shards_acknowledged" : true
+}
+
+// 列出所有索引
+$ curl 'localhost:9200/_cat/indices?v'
+health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
+yellow open helloworld nE6isWA2TaCdePngczJeJw 5 1 0 0 650b 650b
+```
+
+黄色健康标签, 状态 open
+
+
+让我们将一个简单的客户文档索引到 helloworld 索引、“external”类型中,这个文档的ID是1,操作如下:
+
+$curl -XPUT 'localhost:9200/helloworld/external/1?pretty' -d '{"name":"wangyt"}'
+{
+ "_index" : "helloworld",
+ "_type" : "external",
+ "_id" : "1",
+ "_version" : 1,
+ "result" : "created",
+ "_shards" : {
+ "total" : 2,
+ "successful" : 1,
+ "failed" : 0
+ },
+ "created" : true
+}
+
+```
+$ curl 'localhost:9200/_cat/indices?v'
+health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
+yellow open helloworld nE6isWA2TaCdePngczJeJw 5 1 1 0 3.7kb 3.7kb
+```
+
+有5个主分片和1份复制(都是默认值),其中包含0个文档。
+docs.count 1
+store.size 3.7kb
+pri.store.size 3.7kb
+
+列出所有索引,使用json格式
+$ curl 'localhost:9200/_cat/indices?format=json&pretty&v'
+[
+ {
+ "health" : "yellow",
+ "status" : "open",
+ "index" : "helloworld",
+ "uuid" : "nE6isWA2TaCdePngczJeJw",
+ "pri" : "5",
+ "rep" : "1",
+ "docs.count" : "1",
+ "docs.deleted" : "0",
+ "store.size" : "3.8kb",
+ "pri.store.size" : "3.8kb"
+ }
+]
+
+$ curl -XPUT 'localhost:9200/hello.search?format=json&pretty'
+{
+ "acknowledged" : true,
+ "shards_acknowledged" : true
+}
+
+$ curl 'localhost:9200/_cat/indices?pretty'
+health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
+yellow open hello.search HByjj1YOSwWed-83m9SmYw 5 1 0 0 650b 650b
+yellow open helloworld nE6isWA2TaCdePngczJeJw 5 1 1 0 3.8kb 3.8kb
+
+
+$ curl -XPUT 'localhost:9200/hello.search/external/1?pretty' -d '{"name":"Mr.Wang"}'
+$ curl -XPUT 'localhost:9200/hello.search/external/2?pretty' -d '{"name":"Mr.Yong"}'
+$ curl -XPUT 'localhost:9200/hello.search/external/3?pretty' -d '{"name":"Mr.Tao"}'
+
+$ curl 'localhost:9200/_cat/indices?pretty'
+yellow open hello.search HByjj1YOSwWed-83m9SmYw 5 1 4 0 13.2kb 13.2kb
+yellow open helloworld nE6isWA2TaCdePngczJeJw 5 1 1 0 3.8kb 3.8kb
+
+$ curl 'localhost:9200/_cat/indices?pretty&v'
+health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
+yellow open hello.search HByjj1YOSwWed-83m9SmYw 5 1 4 0 13.2kb 13.2kb
+yellow open helloworld nE6isWA2TaCdePngczJeJw 5 1 1 0 3.8kb 3.8kb
+
+删除API,可以根据特定的ID删除文档。
+
+$ curl -XDELETE 'http://localhost:9200/hello.search/external/2?pretty'
+{
+ "found" : true,
+ "_index" : "hello.search",
+ "_type" : "external",
+ "_id" : "2",
+ "_version" : 3,
+ "result" : "deleted",
+ "_shards" : {
+ "total" : 2,
+ "successful" : 1,
+ "failed" : 0
+ }
+}
+
+// 删除 hello.search 全部索引
+$ curl -XDELETE 'http://localhost:9200/hello.search?pretty'
+{
+ "acknowledged" : true
+}
+
+在添加索引的时候,ID部分是可选的。
+如果不指定,Elasticsearch将产生一个随机的ID来索引这个文档。
+
+以下的例子展示了怎样在没有指定ID的情况下来索引一个文档:
+
+curl -XPOST 'localhost:9200/hello.search/external?pretty' -d '{"name":"Tom.Cat.Dog.Fish"}'
+{
+ "_index" : "hello.search",
+ "_type" : "external",
+ "_id" : "AVtBBCwvPvrk6DMcZhkn",
+ "_version" : 1,
+ "result" : "created",
+ "_shards" : {
+ "total" : 2,
+ "successful" : 1,
+ "failed" : 0
+ },
+ "created" : true
+}
+注意,在上面的实例中,由于我们没有指定一个ID,使用的是 POST 而不是 PUT, 生成了随机的ID:AVtBBCwvPvrk6DMcZhkn 。
+
+搜索的REST API可以通过_search端点来访问。下面这个例子返回bank索引中的所有的文档:
+
+curl 'localhost:9200/hello.search/_search?q=*&pretty'
+
+curl 'localhost:9200/hello.search/_search?q=name:Mr.Yong&pretty'
+{
+ "took" : 2,
+ "timed_out" : false,
+ "_shards" : {
+ "total" : 5,
+ "successful" : 5,
+ "failed" : 0
+ },
+ "hits" : {
+ "total" : 1,
+ "max_score" : 0.2876821,
+ "hits" : [
+ {
+ "_index" : "hello.search",
+ "_type" : "external",
+ "_id" : "2",
+ "_score" : 0.2876821,
+ "_source" : {
+ "name" : "Mr.Yong"
+ }
+ }
+ ]
+ }
+}
+
+
+curl 'localhost:9200/hello.search/_search?q=name:Mr*&pretty'
+{
+ "took" : 20,
+ "timed_out" : false,
+ "_shards" : {
+ "total" : 5,
+ "successful" : 5,
+ "failed" : 0
+ },
+ "hits" : {
+ "total" : 3,
+ "max_score" : 1.0,
+ "hits" : [
+ {
+ "_index" : "hello.search",
+ "_type" : "external",
+ "_id" : "2",
+ "_score" : 1.0,
+ "_source" : {
+ "name" : "Mr.Yong"
+ }
+ },
+ {
+ "_index" : "hello.search",
+ "_type" : "external",
+ "_id" : "1",
+ "_score" : 1.0,
+ "_source" : {
+ "name" : "Mr.Wang"
+ }
+ },
+ {
+ "_index" : "hello.search",
+ "_type" : "external",
+ "_id" : "3",
+ "_score" : 1.0,
+ "_source" : {
+ "name" : "Mr.Tao"
+ }
+ }
+ ]
+ }
+}
+
+ 对于这个响应,我们看到了以下的部分:
+ - took —— Elasticsearch执行这个搜索的耗时,以毫秒为单位
+ - timed_out —— 指明这个搜索是否超时
+ - _shards —— 指出多少个分片被搜索了,同时也指出了成功/失败的被搜索的shards的数量
+ - hits —— 搜索结果
+ - hits.total —— 能够匹配我们查询标准的文档的总数目
+ - hits.hits —— 真正的搜索结果数据(默认只显示前10个文档)
+ - _score和max_score —— 现在先忽略这些字段
+
+
+curl -XPOST 'localhost:9200/hello.search/_search?pretty' -d '{"query":{"match_all":{}}}'
+
+curl -XPOST 'localhost:9200/hello.search/_search?pretty' -d '{"query":{"match_all":{}}}'
+curl -XGET 'localhost:9200/hello.search/_search?pretty' -d '
+ {
+ "query": {
+ "match": {
+ "name":"Mr."
+ }
+ }
+ }'
diff --git a/elasticsearch/Kibana-Quick-Start.md b/elasticsearch/Kibana-Quick-Start.md
new file mode 100644
index 0000000..9f65bd8
--- /dev/null
+++ b/elasticsearch/Kibana-Quick-Start.md
@@ -0,0 +1 @@
+http://localhost:5601
diff --git a/elasticsearch/Logstash-Quick-Start.md b/elasticsearch/Logstash-Quick-Start.md
new file mode 100644
index 0000000..1393d59
--- /dev/null
+++ b/elasticsearch/Logstash-Quick-Start.md
@@ -0,0 +1,41 @@
+
+检测 java 版本
+$ java -version
+java version "1.8.0"
+Java(TM) SE Runtime Environment (build 1.8.0-b132)
+Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
+
+
+
+wget https://artifacts.elastic.co/downloads/logstash/logstash-5.3.0.tar.gz
+
+tar zxf logstash-5.3.0.tar.gz
+
+cd logstash-5.3.0
+
+vi logstash-simple.conf
+
+input { stdin { } }
+output {
+ elasticsearch { hosts => ["localhost:9200"] }
+ stdout { codec => rubydebug }
+}
+
+bin/logstash -f logstash-simple.conf
+
+http://localhost:9600/
+
+{
+ host: "YONG-TEST.local",
+ version: "5.3.0",
+ http_address: "127.0.0.1:9600",
+ id: "6bd6fa7c-1559-42fc-9864-7275a2da3081",
+ name: "YONG-TEST.local",
+ build_date: "2017-03-23T03:56:19Z",
+ build_sha: "da58f0946883e10b4472f6ade80d38b6e02947be",
+ build_snapshot: false
+}
+
+To enable automatic config reloading, start Logstash with the --config.reload.automatic (or -r) command-line option specified. For example:
+
+bin/logstash –f apache.config --config.reload.automatic
\ No newline at end of file
diff --git a/installation/README.md b/installation/README.md
new file mode 100644
index 0000000..c55c37b
--- /dev/null
+++ b/installation/README.md
@@ -0,0 +1,44 @@
+README.md
+
+
+## 安装版本:
+
+推荐使用最新的版本
+
+PHP 8 联合类型支持、JIT(发布于2020年,推荐安装)
+PHP 7 第三代Zend引擎 (不推荐安装,2022年底停止维护)
+PHP 6 未发布(不存在)
+PHP 5 第二代Zend引擎 (已废弃,不推荐安装,最新版为2019年发布的 PHP 5.6.40)
+
+
+目前(2022年3月),默认安装的是 php 8.1 版本:
+
+```sh
+$ php --version
+PHP 8.1.3 (cli) (built: Mar 1 2022 01:17:32) (NTS)
+Copyright (c) The PHP Group
+Zend Engine v4.1.3, Copyright (c) Zend Technologies
+ with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies
+```
+
+
+## 推荐使用虚拟机
+
+(1) 使用 Homestead 安装 (vagrant + virtualbox)
+
+(2) 使用 docker 安装
+
+
+## Mac 系统安装
+
+使用 brew 安装(有时候会很慢):
+
+```sh
+$ brew install php
+```
+
+## Linux 系统安装
+
+(1)Debian / Ubuntu 可以使用 apt 命令安装。
+
+(2)源码编译安装 (不推荐、费时费力)
diff --git a/installation/SUMMARY.md b/installation/SUMMARY.md
new file mode 100644
index 0000000..e5127ee
--- /dev/null
+++ b/installation/SUMMARY.md
@@ -0,0 +1,6 @@
+SUMMARY.md
+
+ - [Xhprof的安装与使用](installation/php-xhprof-install.md)
+ - [Laravel-Homestead-PHP开发环境安装与配置(推荐)](installation/laravel-homestead-install.md)
+ - [源码安装PHP开发环境](installation/php-install-source.md)
+ - [源码安装Nginx服务器](installation/nginx-install-source.md)
\ No newline at end of file
diff --git a/installation/laravel-homestead-install.md b/installation/laravel-homestead-install.md
new file mode 100644
index 0000000..a7ea8e4
--- /dev/null
+++ b/installation/laravel-homestead-install.md
@@ -0,0 +1,289 @@
+# PHP Laravel-Homestead 开发环境安装与配置
+
+> Laravel Homestead 是一个官方预载的 Vagrant「封装包」,提供你一个美好的开发环境,不需要在本机端安装 PHP、HHVM、网页服务器或任何服务器软件。
+> Homestead 可以在任何 Windows、Mac 或 Linux 上面运行,里面包含了 Nginx 网页服务器、PHP 5.6、MySQL、Postgres、Redis、Memcached等软件,
+> 还有所有你要开发精彩的 Laravel 应用程序所需的软件。
+
+### 本机系统环境:
+
+```
+//使用 uname 查看当前操作系统名称
+$ uname -mnprs
+Darwin YONG-TEST.local 15.6.0 x86_64 i386
+
+//使用sw_vers 查看 macOS版本信息
+$ sw_vers
+ProductName: Mac OS X
+ProductVersion: 10.11.6
+BuildVersion: 15G31
+```
+
+### 不使用用Homestead,直接在本机安装:
+
+使用homebrew安装PHP7:
+
+$ brew update
+$ brew search php70
+homebrew/php/php70
+homebrew/php/php70-gmagick
+homebrew/php/php70-maxminddb
+homebrew/php/php70-pdo-pgsql
+homebrew/php/php70-stats
+homebrew/php/php70-amqp
+...
+
+$ brew install homebrew/php/php70
+
+配置php-fpm端口为9002, 因为本机已经安装了php5, 占用了9001端口。
+
+配置Nginx配置文件:
+
+重启Nginx服务器。
+
+
+### 安装Homestead Vagrant Box:
+
+下载 Homestead:
+
+```
+$ git clone https://github.com/laravel/homestead.git Homestead
+$ cd Homestead/
+$ ls
+CHANGELOG.md Vagrantfile composer.lock init.bat readme.md /src
+LICENSE.txt composer.json homestead init.sh /scripts
+$ bash init.sh
+```
+
+下载 Homestead Vagrant Box:
+
+$ vagrant box add laravel/homestead
+
+执行示例:
+
+```
+//下载安装laravel/homestead:
+$ vagrant box add laravel/homestead --force
+==> box: Loading metadata for box 'laravel/homestead'
+box: URL: https://atlas.hashicorp.com/laravel/homestead
+==> box: Adding box 'laravel/homestead' (v0.5.0) for provider: virtualbox
+box: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.5.0/providers/virtualbox.box
+box: Progress: 5% (Rate: 572k/s, Estimated time remaining: 0:33:13)
+...
+
+//下载成功后显示如下:
+==> box: Successfully added box 'laravel/homestead' (v0.5.0) for 'virtualbox'!
+```
+
+### 启动虚拟机
+
+```
+$ vagrant up
+Bringing machine 'default' up with 'virtualbox' provider...
+There are errors in the configuration of this machine. Please fix the following errors and try again:
+vm: * The host path of the shared folder is missing: ~/Code
+//报错没有“~/Code”目录,那我们就创建一个:
+$ mkdir ~/Code
+$ vagrant up
+```
+
+打开VirtualBox中,可以看到有一个名为"homestead-7"的虚拟机正在运行(状态为:Running)。
+
+
+### 配置Hosts文件:
+
+```
+$ sudo vi /etc/hosts
+//增加一条记录:
+192.168.10.10 homestead.app
+```
+
+Make sure the IP address listed is the one set in your ~/.homestead/Homestead.yaml file.
+
+
+### 使用laravel创建一个站点:
+
+$ cd ~/Code
+$ composer require laravel/homestead --dev
+
+配置文件“Homestead.yaml”里包含一个示例站点配置.
+注意默认的站点是"/home/vagrant/Code/Laravel/public",
+所以我们现在创建在~/Code下面创建一个名为"Laravel"。
+
+$ laravel new Laravel
+-bash: laravel: command not found
+
+$ ~/.composer/vendor/bin/laravel new Laravel
+
+/home/vagrant/Code/Laravel/public
+
+打开浏览器,输入"http://homestead.app/", 即可正常访问。
+
+
+### 配置 Homestead
+
+配置文件路径是: ~/.homestead/Homestead.yaml
+
+配置文件内容如下:
+```
+ip: "192.168.10.10"
+memory: 2048
+cpus: 1
+provider: virtualbox
+authorize: ~/.ssh/id_rsa.pub
+keys:
+ - ~/.ssh/id_rsa
+folders:
+ - map: ~/Code
+ to: /home/vagrant/Code
+sites:
+ - map: homestead.app
+ to: /home/vagrant/Code/Laravel/public
+databases:
+ - homestead
+```
+
+配置示例: 新增一个网站"kaixin123.app":
+
+(1) 新增网站目录"kaixin123net":
+ 在Code目录中新增一个kaixin123net目录,作为新增网站的根目录:
+ 创建一个index.html文件,随便写写内容,比如"hello,kaixin123.app":
+ 路径如下: ~/Code/kaixin123net/index.html
+
+(2) 增加sites:
+```
+$ vim ~/.homestead/Homestead.yaml
+
+//在sites中新增一条map记录,修改后配置如下:
+//配置中的xunij “/home/vagrant/Code/kaixin123net” 对应我们本地的 "~/Code/kaixin123net"
+sites:
+ ### 默认
+ - map: homestead.app
+ to: /home/vagrant/Code/Laravel/public
+ ### 新增加一个网站,域名为kaixin123.app
+ - map: kaixin123.app
+ to: /home/vagrant/Code/kaixin123net
+```
+(3) 新增一条host记录:
+```
+$ sudo vim /etc/hosts
+
+//新增一条host记录,IP是Homestead.yaml中“ip”,修改后如下:
+... (略) ...
+192.168.10.10 homestead.app
+192.168.10.10 kaixin123.app
+
+```
+(4) 打开浏览器,输入"http://kaixin123.app/", 可以正常访问。
+
+如果重新修改配置,需要重新加载vagrant:
+
+```
+$ cd /Users/WangTom/Homestead
+$ vagrant reload --provision
+```
+
+登录虚拟机:
+
+$ cd ~/Homestead/
+$ vagrant ssh
+
+```
+/进入~/Homestead/目录
+YONGTEST:~ WangTom$ cd ~/Homestead/
+YONGTEST:Homestead WangTom$
+
+//登录虚拟机
+YONGTEST:Homestead WangTom$ vagrant ssh
+Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)
+ * Documentation: https://help.ubuntu.com/
+Last login: Fri Sep 23 06:42:33 2016 from 10.0.2.2
+
+//有Code文件夹,这个/home/vagrant/Code与本机的~/Code目录会保持同步
+vagrant@homestead:~$ ls
+Code
+
+//退出虚拟机
+vagrant@homestead:~$ exit
+logout
+Connection to 127.0.0.1 closed.
+```
+
+
+连接Homestead数据库:
+
+>
+> To connect to your MySQL or Postgres database from your host machine via Navicat or Sequel Pro:
+> Connect to 127.0.0.1 and port 33060 (MySQL) or 54320 (Postgres).
+> The username and password for both databases is homestead / secret.
+
+地址: 192.168.10.10
+端口: 3306
+用户名: homestead
+密码: secret
+
+
+登录虚拟机数据库:
+
+```
+vagrant@homestead:~$ mysql -h192.168.10.10 -uhomestead -p
+Enter password:
+Welcome to the MySQL monitor. Commands end with ; or \g.
+Your MySQL connection id is 51
+Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu)
+Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+Oracle is a registered trademark of Oracle Corporation and/or its
+affiliates. Other names may be trademarks of their respective
+owners.
+Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
+mysql> show databases;
++--------------------+
+| Database |
++--------------------+
+| information_schema |
+| homestead |
+| mysql |
+| performance_schema |
+| sys |
++--------------------+
+5 rows in set (0.00 sec)
+mysql>
+```
+
+以后再次启动/登录:
+$ cd ~/Homestead/
+$ vagrant up
+$ vagrant ssh
+
+
+### 扩展阅读
+
+(1) brew
+
+brew(即Homebrew), 是macOS上的软件包管理工具, 能在Mac中方便的安装软件或者卸载软件,类似ubuntu系统下的apt-get的功能.
+Homebrew- The missing package manager for OS X
+http://brew.sh/
+
+(2) Vagrant
+
+Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境。它使用Oracle的开源VirtualBox虚拟化系统,使用Chef创建自动化虚拟环境。
+https://www.vagrantup.com/
+
+(3) Laravel
+
+Laravel是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。
+https://laravel.com/
+
+
+### 参考资料
+
+https://laravel.com/docs/5.3/homestead
+http://laravelacademy.org/post/2749.html
+http://laravel-china.org/docs/5.1/homestead
+https://www.vagrantup.com/docs/getting-started/
+
+
+### 更新记录
+
+1. 20160825 新增此文档 (wangyt)
+2. 20160829 更新文档,改成Homestead安装与配置 (wangyt)
+3. 20160922 更新文档,新增配置多站点 (wangyt)
diff --git a/installation/nginx-install-source.md b/installation/nginx-install-source.md
new file mode 100644
index 0000000..dce1240
--- /dev/null
+++ b/installation/nginx-install-source.md
@@ -0,0 +1,391 @@
+源码编译安装Nginx服务器
+
+Compiling and Installing From the Sources
+
+
+## 1 安装前准备:
+
+1-1 检测本地环境:
+```
+$ sw_vers
+ProductName: Mac OS X
+ProductVersion: 10.11.3
+BuildVersion: 15D21
+
+$ uname -mnprs
+Darwin MacWangYongTao.local 15.3.0 x86_64 i386
+```
+
+1-2 检测GCC版本:
+```
+$ gcc -v
+Configured with:
+--prefix=/Applications/Xcode.app/Contents/Developer/usr
+--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
+Apple LLVM version 7.0.2 (clang-700.1.81)
+Target: x86_64-apple-darwin15.3.0
+Thread model: posix
+```
+
+1-3 创建安装目录/webserver:
+
+为了方便管理,在/usr/local/下新建一个目录webserver,以后软件安装都可以加"—prefix=/usr/local/webserver"来安装到这个目录下:
+
+```
+$sudo mkdir webserver
+$pwd
+/usr/local/webserver
+```
+
+# 2 安装nginx的依赖库
+
+### 安装pcre:
+
+PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 Perl兼容的 正则表达式库,由菲利普.海泽(Philip Hazel)编写。
+
+
+the PCRE library – required by NGINX Core and Rewrite modules and provides support for regular expressions:
+
+```
+wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.bz2
+tar jxvf pcre-8.41.tar.bz2
+cd pcre-8.41
+./configure --prefix=/usr/local/webserver/pcre-8.41
+make
+make test
+sudo make install
+```
+
+### 下载 zlib 库:
+
+zlib是提供数据压缩用的函式库,目前zlib是一种事实上的业界标准,最新版本是:
+
+ zlib 1.2.11(January 15, 2017)。
+
+zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression).
+
+zlib库是 ngx_http_gzip_module 模块必须安装的,如果不需要nginx gzip压缩的话可以不开启(建议安装并开启)。
+本模块不需要编译安装,只需要讲源码地址告诉 Nginx 即可(使用参数--with-zlib=zlib-path),由 Nginx 来编译安装。
+
+
+```
+# 下载
+wget http://www.zlib.net/zlib-1.2.11.tar.gz
+tar zxvf zlib-1.2.11.tar.gz
+cd zlib-1.2.11
+
+# 如果需要安装,可以执行以下命令
+./configure
+make
+make test
+sudo make install
+```
+
+### 下载 PCRE 库:
+
+PCRE(Perl Compatible Regular Expressions)是一个轻量级的函数库Perl库,包括 perl 兼容的正则表达式库。
+PCRE 库是 ngx_http_rewrite_module 模块必须安装的,主要用来页面重定向和正则替换URI的。
+同 zlib 库一样,本模块不需要编译安装,只需要讲源码地址告诉 Nginx 即可(使用参数--with-pcre=pcre-path),由 Nginx 来编译安装。
+
+
+官方下载地址: https://ftp.pcre.org/pub/pcre/
+
+目前最新的版本是 pcre-8.41 和 pcre2-10.30 两个,由于 Nginx 只支持(version 4.4 — 8.41), 这里我们下载的是 pcre-8.41 版本 。
+
+ wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
+ tar -zxf pcre-8.41.tar.gz
+
+
+### 安装 OpenSSL 库:
+
+OpenSSL 是一个强大的安全套接字层密码库,包括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
+
+the OpenSSL library – required by NGINX SSL modules to support the HTTPS protocol:
+
+```
+$ wget http://www.openssl.org/source/openssl-1.0.2e.tar.gz
+$ tar -zxf openssl-1.0.2e.tar.gz
+$ cd openssl-1.0.2e
+$ ./Configure darwin64-x86_64-cc --prefix=/usr/local/webserver/openssl --openssldir=/usr/local/webserver/openssl
+$ make
+$ sudo make install
+
+查看版本(检测是否安装成功):
+$ /usr/local/webserver/openssl/bin/openssl version
+OpenSSL 1.0.2h 3 May 2016
+
+
+查看OpenSSL支持的平台列表:
+$./Configure LIST
+
+```
+
+注意事项:
+> If configuring for 64-bit OS X, then use a command similar to:
+> $./Configure darwin64-x86_64-cc shared enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macos-x86_64
+> $make depend
+> $sudo make install
+>
+> If configuring for 32-bit OS X, then use a command similar to:
+> ./Configure darwin-i386-cc shared no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macosx-i386
+> $make depend
+> $sudo make install
+
+
+
+## 3 安装Nginx
+
+下载并安装Nginx:
+
+```
+// 指定安装在/usr/local/webserver/目录下:
+$ wget http://nginx.org/download/nginx-1.8.1.tar.gz
+$ tar zxf nginx-1.8.1.tar.gz
+$ export KERNEL_BITS=64
+$ ./configure --prefix=/usr/local/webserver/nginx \
+ --sbin-path=/usr/local/webserver/nginx/nginx \
+ --conf-path=/usr/local/webserver/nginx/nginx.conf \
+ --pid-path=/usr/local/webserver/nginx/nginx.pid \
+ --with-http_ssl_module \
+ --with-openssl=../openssl-1.0.2h \
+ --with-pcre=../pcre-8.41 \
+ --with-zlib=../zlib-1.2.11
+```
+
+
+./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-http_gzip_static_module
+ --with-http_v2_module
+ --with-pcre=../pcre-8.41
+ --with-zlib=../zlib-1.2.11
+
+参数说明:
+
+--sbin-path=path — 设置可执行文件名. 默认是:prefix/sbin/nginx.
+--conf-path=path — 设置配置文件名(nginx.conf). 默认是:prefix/conf/nginx.conf.
+--pid-path=path — 设置存放进程ID的nginx.pid文件名.默认是:prefix/logs/nginx.pid.
+--with-http_ssl_module - 启用支持https协议,依赖OpenSSL库.
+--with-pcre=path - sets the path to the sources of the PCRE library.(注意是源码的路径)
+--with-zlib=path — sets the path to the sources of the zlib library.(注意是源码的路径)
+
+
+## 4 配置Nginx:
+
+配置文件路径: /usr/local/webserver/nginx/nginx.conf
+
+$ sudo /usr/local/webserver/nginx/nginx -t
+nginx: the configuration file /usr/local/webserver/nginx/nginx.conf syntax is ok
+nginx: configuration file /usr/local/webserver/nginx/nginx.conf test is successful
+
+## 5 启动Nginx:
+
+查看版本:
+```
+$ /usr/local/webserver/nginx/nginx -v
+nginx version: nginx/1.8.1
+```
+
+执行启动命令:
+```
+// 启动Nginx,没有报错可以认为启动成功
+$ sudo /usr/local/webserver/nginx/nginx
+```
+
+
+命令查看:
+
+```
+$ curl -I 127.0.0.1
+HTTP/1.1 200 OK
+Server: nginx/1.8.1
+Date: Mon, 01 Feb 2016 12:29:30 GMT
+Content-Type: text/html
+Content-Length: 612
+Last-Modified: Mon, 01 Feb 2016 10:25:21 GMT
+Connection: keep-alive
+ETag: "56af3291-264"
+Accept-Ranges: bytes
+```
+
+浏览器查看:
+
+打开浏览器输入:http://127.0.0.1/ 或者 http://localhost/
+可以看到:"Welcome to nginx! " 页面
+
+其实,这个页面是在 /usr/local/webserver/nginx/html/ 目录下,
+我们尝试新建一个html静态页面:
+```
+$ pwd
+/usr/local/webserver/nginx/html
+$ sudo vi hello.html
+...(随便写入一下内容,比如"Hello,Nginx!",然后保存)..
+
+```
+
+打开浏览器输入:
+http://127.0.0.1/hello.html 或者 http://localhost/hello.html
+可以看到我们刚刚写的静态页面hello.html的内容。
+
+现在Nginx只支持一些静态的内容,如果需要动态内容,还需要安装PHP等。
+
+重新加载:
+$ sudo /usr/local/webserver/nginx/nginx -s reload
+
+
+## 遇到的问题与解决办法
+
+### 报错1: 没有指定 OpenSSL 库.
+
+内容:
+```
+./configure: error: SSL modules require the OpenSSL library.
+You can either do not enable the modules, or install the OpenSSL library
+into the system, or build the OpenSSL library statically from the source
+with nginx by using --with-openssl= option.
+```
+分析: 启用with-http_ssl_module模块,但没有启用openssl, 启用的SSL模块需要依赖openssl库
+解决: configure时增加参数 [with-openssl=../openssl-1.0.2e].
+
+
+### 报错2: 参数配置路径出错
+
+参数with-pcre,如果指定的是with-pcre=/usr/local/webserver/pcre-8.41,则执行 make 时会报错:
+
+```
+/Applications/Xcode.app/Contents/Developer/usr/bin/make -f objs/Makefile
+cd /usr/local/pcre-8.41 \
+ && if [ -f Makefile ]; then /Applications/Xcode.app/Contents/Developer/usr/bin/make distclean; fi \
+ && CC="cc" CFLAGS="-O2 -pipe " \
+ ./configure --disable-shared
+/bin/sh: ./configure: No such file or directory
+make[1]: *** [/usr/local/webserver/pcre-8.41/Makefile] Error 127
+make: *** [build] Error 2
+```
+
+分析: set path to PCRE library sources, 注意是PCRE的源代码的路径,不是编译安装后的路径
+```
+查看配置帮助:
+$ ./configure --help | grep 'pcre'
+ --without-pcre disable PCRE library usage
+ --with-pcre force PCRE library usage
+ --with-pcre=DIR set path to PCRE library sources
+ --with-pcre-opt=OPTIONS set additional build options for PCRE
+ --with-pcre-jit build PCRE with JIT compilation support
+```
+
+注意这里的路径是 PCRE library sources, 是PCRE的源代码。
+直接去官网下载PCRE, 解压至与 nginx-1.8.1 平级的目录中(或者其他的路径)。
+
+解决: 将PCRE路径指定为源代码的路径,比如:with-pcre=/softwares/pcre-8.41
+
+### 报错3 :
+$ sudo ./config --prefix=/usr/local/openssl
+Operating system: i686-apple-darwinDarwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015;
+root:xnu-3248.30.4~1/RELEASE_X86_64
+WARNING! If you wish to build 64-bit library, then you have to
+ invoke './Configure darwin64-x86_64-cc' *manually*.
+ You have about 5 seconds to press Ctrl-C to abort.
+
+解决: 配置命令使用 Configure, 而不是config, 加参数平台参数:darwin64-x86_64-cc
+$ sudo ./Configure darwin64-x86_64-cc --prefix=/usr/local/openssl
+备注: 查看支持的平台列表:$./Configure LIST
+
+### 报错4:Undefined symbols for architecture x86_64
+
+```
+Undefined symbols for architecture x86_64:
+ "_SSL_CTX_set_alpn_select_cb", referenced from:
+ _ngx_http_ssl_merge_srv_conf in ngx_http_ssl_module.o
+ "_SSL_CTX_set_next_protos_advertised_cb", referenced from:
+ _ngx_http_ssl_merge_srv_conf in ngx_http_ssl_module.o
+ "_SSL_select_next_proto", referenced from:
+ _ngx_http_ssl_alpn_select in ngx_http_ssl_module.o
+ "_X509_check_host", referenced from:
+ _ngx_ssl_check_host in ngx_event_openssl.o
+ld: symbol(s) not found for architecture x86_64
+clang: error: linker command failed with exit code 1 (use -v to see invocation)
+make[1]: *** [objs/nginx] Error 1
+make: *** [build] Error 2
+
+```
+分析: 这个报错在网上有好多种原因造成的,因此也有许多的解决办的。
+只要系统是64位系统,然后configure前在指明一下是64位系统,就没问题了。
+解决:
+(1)将openssl-1.0.2e目录中, 文件Makefile中的[darwin-i386-cc]全部替换成[darwin64-x86_64-cc]
+(2)检测自己的系统是以32位模式运行,还是以64位模式运行,确保是以64位模式运行。
+(3)要为当前启动磁盘选择 64 位内核,请在“终端”中使用下列命令:sudo systemsetup -setkernelbootarchitecture x86_64
+```
+// 但是设置没有生效:
+$ sudo systemsetup -setkernelbootarchitecture x86_64
+Password:
+setting kernel architecture to: x86_64
+changes to kernel architecture failed to save!
+```
+(4) 执行配置NGINX命令前,增加 export KERNEL_BITS=64 命令,指定系统的运行模式为64位的。
+
+### 报错5: 重启NGIXN报错:
+内容:
+nginx: [error] open() "/usr/local/webserver/nginx/nginx.pid" failed (2: No such file or directory)
+
+分析:
+解决:使用nginx -c的参数指定nginx.conf文件的位置:
+/usr/local/webserver/nginx/nginx -c /usr/local/webserver/nginx/nginx.conf
+
+注意这里的nginx路径,在编译时有指定,可能像网上的有些不同,默认应该是:
+/usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
+
+```
+检测配置文件是否正确: (出错了,没有找到nginx.conf文件)
+$ sudo /usr/local/webserver/nginx/nginx -t
+nginx: [emerg] open() "/usr/local/webserver/nginx/nginx.conf" failed (2: No such file or directory)
+nginx: configuration file /usr/local/webserver/nginx/nginx.conf test failed
+
+复制配置文件:(复制一份)
+$sudo cp nginx.conf.default nginx.conf
+
+再次检测: (OK)
+$ sudo /usr/local/webserver/nginx/nginx -t
+nginx: the configuration file /usr/local/webserver/nginx/nginx.conf syntax is ok
+nginx: configuration file /usr/local/webserver/nginx/nginx.conf test is successful
+```
+
+
+## 用到的一些命令
+
+```
+$ ps -ef |grep nginx
+$ kill -9 [pid]
+$ arch
+$ uname -a
+$ ioreg -l -p IODeviceTree | grep "firmware-abi" | sed -e 's/[^0-9A-Z]//g'
+
+```
+
+
+## 参考资料
+
+http://nginx.org/en/docs/configure.html
+
+https://www.nginx.com/resources/admin-guide/installing-nginx-open-source/
+
+http://segmentfault.com/a/1190000003822041?_ea=392297
+
+http://lists.apple.com/archives/macnetworkprog/2015/Jun/msg00025.html
+
+http://www.iyunv.com/thread-18789-1-1.html
+
+https://wiki.openssl.org/index.php/Compilation_and_Installation#Mac
+
+http://www.nooidea.com/2011/02/switch-mac-into-64-bit.html
+
+
+## 更新记录
+
+Update 2016/01/28: Updated for nginx-1.8.1.
+Update 2016/05/17: 更新到openssl-1.0.2h,修改一些内容.
+
+[END]
diff --git a/installation/php-install-source.md b/installation/php-install-source.md
new file mode 100644
index 0000000..267876d
--- /dev/null
+++ b/installation/php-install-source.md
@@ -0,0 +1,301 @@
+
+- 如何安装PHP开发环境
+
+-- PHP官网: http://php.net/manual/zh/install.php
+
+在 Unix/Linux 平台下安装 PHP 有几种方法:使用配置和编译过程,或是使用各种预编译的包。
+本文主要针对配置和编译 PHP 的过程。
+很多 Unix 类系统都有包安装系统,可以用它来设置一个有着标准配置的 PHP。
+但是若需要与标准配置不同的功能(例如一个安全服务器,或者不同的数据库驱动扩展模块),可能需要编译 PHP 和/或 web 服务器。
+如果不熟悉编译软件,可以考虑搜索一下是否有人已经编译了包含所需要功能的预编译包。
+
+### PHP开发环境包括什么
+
+服务器: Nginx, Apache
+语言:PHP
+数据库: MySQL, Sqlite, MongoDB, Redis
+缓存: Memcache, Redis
+
+
+
+### 如何安装PHP开发环境
+
+1 使用一键安装包:
+
+Windows系统:
+
+> PHPStudy:
+> http://www.phpstudy.net/
+
+> AppServ:
+> http://www.appservnetwork.com/en/
+
+> WampServer:
+> http://www.wampserver.com/
+
+> UPUPW:
+> http://www.upupw.net/
+
+> XAMPP:支持Windows/Linux/MacOS平台
+> https://www.apachefriends.org/zh_cn/index.html
+
+Linux系统:
+
+> http://lnmp.org/
+> http://www.lanmps.com/
+> XAMPP:支持Windows/Linux/MacOS平台
+> https://www.apachefriends.org/zh_cn/index.html
+
+2 使用源码编译安装:
+
+Linux: CentOS, Ubuntu
+Mac: OS X
+
+
+### 如何使用源码编译安装PHP环境
+
+> + OpenSSl
+> + Mcrypt
+> + zlib
+> + freetype
+> + jpeg
+> + 安装libpng
+> + MySQL:
+
+
+
+##### 安装 OpenSSl :
+
+官网:http://www.openssl.org/
+简介:OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
+下载:http://www.openssl.org/source/openssl-1.0.2a.tar.gz
+
+参见:
+Mac-64-bit: http://wiki.openssl.org/index.php/Compilation_and_Installation#Mac
+
+```
+- wget http://www.openssl.org/source/openssl-1.0.2a.tar.gz
+- cd openssl-1.0.2a
+- ./Configure darwin64-x86_64-cc enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macos-x86_64
+- make
+- sudo make install
+```
+
+
+### 安装 Mcrypt:
+> # 官网:
+> http://mcrypt.hellug.gr/
+> # 下载:
+> ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt
+> wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
+
+
+### 安装 zlib:
+
+> # 官网:
+> http://www.zlib.net/
+> #简介:
+> zlib是提供数据压缩用的函式库,由Jean-loup Gailly与Mark Adler所开发,初版0.9版在1995年5月1日发表。zlib使用DEFLATE算法,最初是为libpng函式库所写的,后来普遍为许多软件所使用。此函式库为自由软件,使用zlib授权。
+
+```
+$ wget http://zlib.net/zlib-1.2.8.tar.gz
+$ ./configure --prefix=/usr/local/lib/zlib
+$ make
+$ make install
+```
+
+### 安装 libiconv (字符编码转换库)
+
+# 网站: http://www.gnu.org/software/libiconv/
+# 当前版本: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
+
+$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
+$ tar zxvf libiconv-1.14.tar.gz
+$ cd libiconv-1.14
+$ ./configure --prefix=/usr/local/lib/libiconv
+$ make
+$ sudo make install
+
+
+
+### 安装freetype
+- tar xzvf freetype-2.1.5.tar.gz (http://freetype.sourceforge.net/download.html#stable)
+- cd freetype-2.1.5
+- ./configure --prefix=/usr/local/modules/freetype
+- make
+- make install
+
+# 安装 jpeg:
+> http://www.ijg.org/
+> http://www.ijg.org/files/
+> wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
+>
+> - $ wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
+> - $ tar zxf jpegsrc.v9.tar.gz
+> - $ cd jpeg-9/
+> - $ ./configure --prefix=/usr/local/lib/jpeg9
+> - $ make
+> - $ sudo make install
+
+### 安装libpng:
+> # 网站:
+> http://libmng.com/pub/png/libpng.html
+> #下载:
+> http://sourceforge.net/projects/libpng/
+> ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.17.tar.gz
+>
+>
+>
+>
+>
+
+### 安装 MySQL:
+> http://dev.mysql.com/downloads/
+>
+>
+>
+>
+>
+
+libevent
+https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
+
+http://pecl.php.net/get/xhprof-0.9.4.tgz
+
+
+
+
+```
+ ./configure \
+ --prefix=/usr/local/php \
+ --with-config-file-path=/usr/local/php \
+ --with-mysql \
+ --with-mysqli \
+ --enable-pdo \
+ --with-pdo-mysql \
+ --with-mysql-sock=/tmp/mysql.sock \
+ --enable-opcache \
+ --enable-cgi \
+ --enable-fpm \
+ --enable-sockets \
+ --enable-mbstring \
+ --enable-mbregex \
+ --enable-bcmath \
+ --enable-xml \
+ --enable-zip \
+ --with-zlib=/usr/local/lib/zlib \
+ --with-gd \
+ --with-png-dir=/usr/local/lib/libpng \
+ --with-jpeg-dir=/usr/local/lib/libjpeg \
+ --with-openssl=/usr/local/ssl/macos-x86_64/ \
+ --with-curl=/usr/local/curl \
+ --with-mhash=/usr/local/lib/libmhash \
+ --with-mcrypt=/usr/local/lib/libmcrypt \
+ --with-iconv=/usr/local/lib/libiconv \
+```
+
+```
+# 报错:OpenSSL
+... ...
+checking for DSA_get_default_method in -lssl... no
+checking for X509_free in -lcrypto... yes
+checking for RAND_egd... no
+checking for pkg-config... no
+configure: error: Cannot find OpenSSL's
+Mac-mini:php-5.6.9 WangTom$
+```
+
+
+Mac-mini:php-5.6.9 WangTom$ which openssl
+/usr/bin/openssl
+
+
+修改openssl参数地址:
+--with-openssl=/usr/local/ssl/macos-x86_64/
+
+```
+# 报错:zlib
+... ...
+checking bundled sqlite3 library... yes
+checking for ZLIB support... yes
+checking if the location of ZLIB install directory is defined... no
+configure: error: Cannot find libz
+Mac-mini:php-5.6.9 WangTom$
+```
+修改openssl参数地址:
+--with-openssl=/usr/local/lib/zlib
+
+
+```
+# 报错: curl
+执行configure配置时报错:
+... ...
+checking whether to enable ctype functions... yes
+checking for cURL support... yes
+checking for cURL in default path... not found
+configure: error: Please reinstall the libcurl distribution -
+ easy.h should be in /include/curl/
+$
+```
+curl-7.49.0.tar.bz2 (7.1M)
+$ wget https://curl.haxx.se/download/curl-7.49.0.tar.bz2
+$ wget http://www.execve.net/curl/curl-7.49.0.tar.bz2 (备选下载地址)
+$ tar jxf curl-7.49.0.tar.bz2
+$ cd curl-7.49.0
+$ ./configure --prefix=/usr/local/webserver/curl
+$ make
+$ sudo make install
+
+$ /usr/local/webserver/curl/bin/curl -V
+curl 7.49.0 (x86_64-apple-darwin15.3.0) libcurl/7.49.0 zlib/1.2.5
+Protocols: dict file ftp gopher http imap ldap ldaps pop3 rtsp smtp telnet tftp
+Features: IPv6 Largefile libz UnixSockets
+
+
+
+
+```
+# 报错: cURL
+checking whether to enable ctype functions... yes
+checking for cURL support... yes
+checking for cURL in default path... not found
+configure: error: Please reinstall the libcurl distribution -
+ easy.h should be in /include/curl/
+```
+
+
+Mac-mini:php-5.6.9 WangTom$ brew --config
+HOMEBREW_VERSION: 0.9.5
+ORIGIN: https://github.com/Homebrew/homebrew
+HEAD: 5b151e438b20f68afadbc9a6df2a01a0cc52b383
+Last commit: 3 weeks ago
+HOMEBREW_PREFIX: /usr/local
+HOMEBREW_CELLAR: /usr/local/Cellar
+CPU: 8-core 64-bit ivybridge
+OS X: 10.10.3-x86_64
+Xcode: 6.3.2
+CLT: N/A
+Clang: 6.1 build 602
+X11: N/A
+System Ruby: 2.0.0-p481
+Perl: /usr/bin/perl
+Python: /usr/bin/python
+Ruby: /usr/bin/ruby
+Java: 1.8.0
+
+Mac-mini:~ WangTom$ sudo ln -s /Applications/Xcode6-Beta4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include /usr/include
+
+Mac-mini:~ WangTom$ ls -l /usr/include
+lrwxr-xr-x 1 root wheel 118 6 19 14:18 /usr/include -> /Applications/Xcode6-Beta4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/installation/php-xhprof-install.md b/installation/php-xhprof-install.md
new file mode 100644
index 0000000..561c4d4
--- /dev/null
+++ b/installation/php-xhprof-install.md
@@ -0,0 +1,270 @@
+PHP性能分析工具-Xhprof的安装与使用
+
+
+XHProf 是一个轻量级的分层性能测量分析器。
+
+XHProf 包含了一个基于 HTML 的简单用户界面(由 PHP 写成)。 基于浏览器的用户界面使得浏览、分享性能数据结果更加简单方便。 同时也支持查看调用图。
+
+XHProf 的报告对理解代码执行结构常常很有帮助。 比如此分层报告可用于确定在哪个调用链里调用了某个函数。
+
+## 本机环境
+
+PHP 版本:
+
+```
+# 系统默认的php位置:
+$ which php
+/usr/local/bin/php
+# 本机使用的php版本为php5.4(不使用系统自动的)
+$ /usr/local/webserver/php54/bin/php -v
+PHP 5.4.44 (cli) (built: May 20 2016 10:19:39)
+Copyright (c) 1997-2014 The PHP Group
+Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
+```
+
+## 使用 phpize 动态安装扩展
+
+本机的Nginx和PHP等服务软件都安装在"/usr/local/webserver”目录下:
+
+```
+# 系统默认phpize
+$ which phpize
+/usr/local/bin/phpize
+
+# 本机安装的phpize版本(不使用系统自动的):
+$ cd /usr/local/webserver/php54/bin/
+$ ls
+pear peardev pecl phar phar.phar php php-cgi php-config phpize
+$ /usr/local/webserver/php54/bin/phpize
+$ /usr/local/webserver/php54/bin/phpize -v
+Configuring for:
+PHP Api Version: 20100412
+Zend Module Api No: 20100525
+Zend Extension Api No: 220100525
+```
+
+下载与安装 xhprof:
+
+```
+$ cd /usr/local/webserver
+$ wget http://pecl.php.net/get/xhprof-0.9.4.tgz
+$ tar zxf xhprof-0.9.4.tgz
+$ cd xhprof-0.9.4
+//配置xhprof, 注意指定php-config地址
+$ ./configure --with-php-config=/usr/local/webserver/php54/bin/php-config
+$ sudo make
+$ sudo make test
+$ sudo make install
+```
+注意,--with-php-config 中php-config的位置,不同的环境中可能会有不同的路径。
+
+## 配置 php.ini
+
+本机的 PHP 配置文件 php.ini文件在: /usr/local/webserver/php54/php.ini :
+```
+$ ls -l
+total 136
+drwxr-xr-x 11 root admin 374 5 20 10:26 bin
+drwxr-xr-x 5 root admin 170 5 20 12:53 etc
+drwxr-xr-x 3 root admin 102 5 20 10:22 include
+drwxr-xr-x 3 root admin 102 5 20 10:22 lib
+drwxr-xr-x 4 root admin 136 5 20 10:22 php
+-rw-r--r--@ 1 root admin 65690 9 9 13:54 php.ini
+drwxr-xr-x 3 root admin 102 5 20 10:22 sbin
+drwxr-xr-x 4 root admin 136 5 20 10:22 var
+```
+
+在 php.ini 中末尾增加如下内容:
+
+```
+[xhprof]
+extension=xhprof.so;
+xhprof.output_dir=/tmp/xhprof
+```
+
+注意,xhprof.output_dir指定的目录 /tmp/xhprof/ 一定要有读写权限
+
+然后重启PHP-fpm/Nginx:
+```
+$ sudo /usr/local/webserver/php54/sbin/php-fpm
+$ sudo /usr/local/webserver/nginx/nginx -s reload
+```
+注意,不同的环境于配置下,php与nginx的安装路径可能会有不同。
+
+查看是否安装成功:
+```
+$ /usr/local/webserver/php54/bin/php -i |grep xhprof
+xhprof
+xhprof => 0.9.2
+```
+
+使用XHProf的时候,在点击[View Full Callgraph]查看结果分析图时,会报错.
+
+ failed to execute cmd: " dot -Tpng". stderr: `sh: dot: command not found `
+
+原因是缺少graphviz绘图软件, 可以使用brew来安装graphviz。
+
+```
+$ brew search graphviz
+$ brew install graphviz
+```
+
+Ubuntu环境可以使用:
+
+```
+sudo apt-get install graphviz
+```
+
+$ whereis dot
+dot: /usr/bin/dot /usr/share/man/man1/dot.1.gz
+
+
+## Xhprof的使用
+
+嵌入PHP代码
+
+```
+save_run($data, "xhprof");
+var_dump($run_id);
+```
+
+查看生成的报告:
+
+生成的报告,列表页,链接如下:
+ http://localhost/wangyt/xhprof_html/index.php?run=$run_id&source=xhprof
+
+页面中包含如下内容:
+```
+Existing runs:
+ 57d277ccf2464.xhprof.xhprof 2016-09-09 16:50:20
+ 57d277c9e32a3.xhprof.xhprof 2016-09-09 16:50:17
+ 57d27755dc7f5.xhprof.xhprof 2016-09-09 16:48:21
+ ...
+```
+
+点击页面中的链接,会进入相应的报告详情页中.
+比如点击第一个"57d277ccf2464", 链接如下:
+ http://localhost/wangyt/xhprof_html/index.php?run=57d277ccf2464&source=xhprof
+
+页面中会展示一个表格, 表格中会有以下参数指标:
+
+> Function Name 函数名称
+> Calls 调用次数
+> Calls% 调用次数的百分比
+> Incl. Wall Time(microsec) : 包含时间, 包括子函数所有执行时间。
+> IWall% 包含时间所占总时间的百分比
+> Excl. Wall Time(microsec) : 独占时间, 函数本身消耗的时间,不包括子函数执行时间。
+> EWall% 独占时间所占总时间的百分比
+
+点击页面中的 [View Full Callgraph],可以查看图像化的内容展示,链接如下:
+ http://localhost/wangyt/xhprof_html/callgraph.php?run=57d277ccf2464
+
+
+## 在 Homestead(PHP7)环境中安装 XHProf
+
+* 登录到 vagrant 虚拟机
+
+```
+ $ cd ~/homestead
+ $ vagrant ssh
+```
+
+* 安装 XHProf 扩展
+
+```
+ cd ~/Code
+ git clone https://github.com/longxinH/xhprof.git ./xhprof
+ cd xhprof/extension/
+ /usr/bin/phpize
+ ./configure --with-php-config=/usr/bin/php-config
+ make && sudo make install
+```
+
+* 创建一个目录,存放分析结果
+
+```
+ mkdir -p /tmp/xhprof/
+```
+
+* 在文件 `/etc/php/7.1/fpm/php.ini` 增加 xhprof 扩展配置:
+
+```
+ $ sudo vi /etc/php/7.1/fpm/php.ini
+
+ > [xhprof]
+ > extension = xhprof.so
+ > xhprof.output_dir = /tmp/xhprof
+
+ (xhprof.output_dir 内容就是我们刚刚创建的目录)
+```
+
+* 安装graphviz绘图软件 (可选)
+
+```
+ $ sudo apt-get install graphviz
+ $ whereis dot
+ dot: /usr/bin/dot /usr/share/man/man1/dot.1.gz
+```
+
+* 配置访问界面
+
+在本机中增加host记录:
+
+```
+ $ sudo vi /etc/hosts
+ 192.168.10.10 xhprof.app
+```
+
+配置 Homestead.yaml 新增一个网站:
+
+```
+ ...
+ sites:
+ ...
+ - map: xhprof.app
+ to: /home/vagrant/Code/xhprof/xhprof_html
+ ...
+```
+
+重启 vagrant :
+
+ $ vagrant provision
+
+访问: `http://xhprof.app` 即可。
+
+
+## 参考链接:
+
+(1) http://php.net/manual/zh/book.xhprof.php
+(2) http://pecl.php.net/package/xhprof
+(3) http://www.xhprof.com/
+(4) http://my.oschina.net/mickelfeng/blog/496902
+(5) http://avnpc.com/pages/profiler-php-performance-online-by-xhprof
+(6) https://www.goivvy.com/blog/xhprof-php-7
+
+## 更新记录
+
+(1) 20160909 整理本文内容
+(2) 20160912 新增安装 graphviz 内容
+(3) 20170912 新增Homestead(php7)下安装
+
+[END]
\ No newline at end of file
diff --git a/installation/ubuntu-nginx-install-source.md b/installation/ubuntu-nginx-install-source.md
new file mode 100644
index 0000000..762010f
--- /dev/null
+++ b/installation/ubuntu-nginx-install-source.md
@@ -0,0 +1,245 @@
+在Linux上使用源码编译安装 Nginx 服务器(nginx-1.13.6)
+
+Compiling and Installing From the Sources
+
+本文是在 Ubuntu 环境源码安装Nginx的总结。
+
+
+## 1 安装前准备:
+
+检测本地环境:
+
+```
+cat /proc/version
+Linux version 3.13.0-86-generic (buildd@lgw01-19)
+(gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) )
+
+$ uname -mnprs
+Linux iZuf6fu4aqltf25ewmxereZ 3.13.0-86-generic x86_64 x86_64
+```
+
+为了方便集中管理,在/usr/local/下新建一个 webserver 目录,以后软件安装都可以加"—prefix=/usr/local/webserver"来安装到这个目录下。
+
+```
+$sudo mkdir webserver
+$pwd
+/usr/local/webserver
+```
+
+# 2 安装nginx的依赖库
+
+### (2.1)下载 zlib 库:
+
+zlib是提供数据压缩用的函式库,目前zlib是一种事实上的业界标准,最新版本是: zlib 1.2.11(January 15, 2017)。
+
+zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression).
+
+zlib库是 ngx_http_gzip_module 模块必须安装的,如果不需要nginx gzip压缩的话可以不开启(建议安装并开启)。
+本模块不需要编译安装,只需要讲源码地址告诉 Nginx 即可(使用参数--with-zlib=zlib-path),由 Nginx 来编译安装。
+
+```
+# 下载并解压
+wget http://www.zlib.net/zlib-1.2.11.tar.gz
+tar zxvf zlib-1.2.11.tar.gz
+
+# 如果需要安装,可以执行以下命令
+cd zlib-1.2.11
+./configure
+make
+make test
+sudo make install
+```
+
+### (2.2)下载 PCRE 库:
+
+PCRE(Perl Compatible Regular Expressions)是一个轻量级的函数库Perl库,包括 perl 兼容的正则表达式库。
+PCRE 库是 ngx_http_rewrite_module 模块必须安装的,主要用来页面重定向和正则替换URI的。
+同 zlib 库一样,本模块不需要编译安装,只需要讲源码地址告诉 Nginx 即可(使用参数--with-pcre=pcre-path),由 Nginx 来编译安装。
+
+官方下载地址: https://ftp.pcre.org/pub/pcre/
+
+目前最新的版本是 pcre-8.41 和 pcre2-10.30 两个,由于 Nginx 只支持(version 4.4 — 8.41), 这里我们下载的是 pcre-8.41 版本 。
+
+```
+# 下载并解压
+wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
+tar -zxf pcre-8.41.tar.gz
+```
+
+### (2.3) 安装 OpenSSL 库:
+
+OpenSSL 是一个强大的安全套接字层密码库,包括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
+
+the OpenSSL library – required by NGINX SSL modules to support the HTTPS protocol:
+
+```
+$ wget http://www.openssl.org/source/openssl-1.0.2m.tar.gz
+$ tar -zxf openssl-1.0.2m.tar.gz
+$ cd openssl-1.0.2m
+$ sudo make
+$ sudo make install
+
+# 查看版本(检测是否安装成功):
+$ openssl version
+OpenSSL 1.1.0g 2 Nov 2017
+```
+
+
+## 3 安装Nginx
+
+下载并解压:
+
+```
+# 指定安装在/usr/local/webserver/目录下:
+$ wget http://nginx.org/download/nginx-1.13.6.tar.gz
+$ tar zxf nginx-1.13.6.tar.gz
+```
+
+配置与安装: 指定的参数可以按需调整,[详情参看](https://nginx.org/en/docs/);
+
+```
+$ ./configure \
+ --prefix=/usr/local/webserver/nginx-1.13.6 \
+ --sbin-path=/usr/local/webserver/nginx-1.13.6/nginx \
+ --conf-path=/usr/local/webserver/nginx-1.13.6/nginx.conf \
+ --pid-path=/usr/local/webserver/nginx-1.13.6/nginx.pid \
+ --with-http_ssl_module \
+ --with-http_gzip_static_module \
+ --with-http_v2_module \
+ --with-pcre=../pcre-8.41 \
+ --with-zlib=../zlib-1.2.11
+$ sudo make
+$ sudo make install
+```
+
+参数说明:
+
+--sbin-path=path — 设置可执行文件名. 默认是:prefix/sbin/nginx.
+--conf-path=path — 设置配置文件名(nginx.conf). 默认是:prefix/conf/nginx.conf.
+--pid-path=path — 设置存放进程ID的nginx.pid文件名.默认是:prefix/logs/nginx.pid.
+--with-http_ssl_module - 启用支持https协议,依赖OpenSSL库.
+--with-ngx_http_gzip_static_module - gzip压缩.
+--with-http_v2_module - provides support for HTTP/2 and supersedes the ngx_http_spdy_module module.
+--with-pcre=path - sets the path to the sources of the PCRE library.(注意是源码的路径)
+--with-zlib=path — sets the path to the sources of the zlib library.(注意是源码的路径)
+
+## 4 配置 Nginx:
+
+配置文件路径: /usr/local/webserver/nginx/nginx.conf
+
+可以看下 Nginx 的默认配置, 可以看到默认端口是80,默认首页是index.html,默认读取的网站目录是html:
+
+```
+server {
+ listen 80;
+ server_name localhost;
+ location / {
+ root html;
+ index index.html index.htm;
+ }
+}
+```
+
+如果修改了配置文件,可以使用 `-t` 参数来检测一些是否有误,`-s reload`来重启服务:
+
+```
+# 检测配置文件是否有错误
+$ /usr/local/webserver/nginx-1.13.6/nginx -t
+nginx: the configuration file /usr/local/webserver/nginx-1.13.6/nginx.conf syntax is ok
+nginx: configuration file /usr/local/webserver/nginx-1.13.6/nginx.conf test is successful
+# 重启服务
+$ sudo /usr/local/webserver/nginx-1.13.6/nginx -s reload
+```
+
+## 5 启动 Nginx:
+
+查看版本,检测是否安装成功:
+
+```
+$ /usr/local/webserver/nginx-1.13.6/nginx -v
+nginx version: nginx/1.13.6
+```
+
+执行启动命令, 没有报错可以认为启动成功:
+
+```
+// 启动Nginx
+$ sudo /usr/local/webserver/nginx-1.13.6/nginx
+```
+
+## 6 查看 Nginx 运行效果:
+
+
+使用curl命令查看, 可以看到返回值"Server: nginx/1.13.6":
+
+```
+$ curl -I 127.0.0.1
+HTTP/1.1 200 OK
+Server: nginx/1.13.6
+Date: Tue, 21 Nov 2017 06:03:48 GMT
+Content-Type: text/html
+Content-Length: 612
+Last-Modified: Tue, 21 Nov 2017 05:54:40 GMT
+Connection: keep-alive
+ETag: "5a13bfa0-264"
+Accept-Ranges: bytes
+```
+
+浏览器查看:
+
+打开浏览器输入:http://127.0.0.1/ 或者 http://localhost/
+可以看到:"Welcome to nginx! " 页面
+
+其实,这个页面是在 /usr/local/webserver/nginx-1.13.6/html/ 目录下(这是nginx.conf的默认配置,可以修改的),
+我们尝试新建一个html静态页面:
+
+```
+$ pwd
+/usr/local/webserver/nginx-1.13.6/html
+
+$ sudo vi hello.html
+...(随便写入一下内容,比如"Hello,Nginx!",然后保存)..
+
+```
+
+打开浏览器输入:`http://127.0.0.1/hello.html` 或者 `http://localhost/hello.html`
+可以看到我们刚刚写的静态页面hello.html的内容。
+
+现在Nginx只支持一些静态的内容,如果需要动态内容,还需要安装PHP等。
+
+## 用到的一些命令
+
+```
+$ ps -ef |grep nginx
+$ kill -9 [pid]
+$ arch
+$ uname -a
+$ ioreg -l -p IODeviceTree | grep "firmware-abi" | sed -e 's/[^0-9A-Z]//g'
+
+```
+
+
+## 参考资料
+
+http://nginx.org/en/docs/configure.html
+
+https://www.nginx.com/resources/admin-guide/installing-nginx-open-source/
+
+http://segmentfault.com/a/1190000003822041?_ea=392297
+
+http://lists.apple.com/archives/macnetworkprog/2015/Jun/msg00025.html
+
+http://www.iyunv.com/thread-18789-1-1.html
+
+https://wiki.openssl.org/index.php/Compilation_and_Installation#Mac
+
+http://www.nooidea.com/2011/02/switch-mac-into-64-bit.html
+
+
+## 更新记录
+
+Update 2016/01/28: Updated for nginx-1.8.1.
+Update 2016/05/17: 更新到openssl-1.0.2h, 修改了一些内容.
+Update 20167/11/21: 更新到nginx-1.13.6、pcre-8.41、zlib-1.2.11, 修改了一些内容.
+
+[END]
\ No newline at end of file
diff --git a/linux-quick-start/README.md b/linux-quick-start/README.md
new file mode 100644
index 0000000..4310733
--- /dev/null
+++ b/linux-quick-start/README.md
@@ -0,0 +1,52 @@
+README.md
+
+
+查看Linux内核版本
+
+* uname -a
+
+ $ uname -a
+ Linux homestead 4.4.0-81-generic
+ #104-Ubuntu SMP Wed Jun 14 08:17:06 UTC 2017
+ x86_64 x86_64 x86_64 GNU/Linux
+
+
+* cat /proc/version
+
+ $ cat /proc/version
+ Linux version 4.4.0-81-generic (buildd@lgw01-02)
+ (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) )
+ #104-Ubuntu SMP Wed Jun 14 08:17:06 UTC 2017
+
+* sw_vers (仅适用于macOS)
+
+ $ sw_vers
+ ProductName: Mac OS X
+ ProductVersion: 10.12.5
+ BuildVersion: 16F73
+
+查看Linux系统版本
+
+* lsb_release -a
+
+ $ lsb_release -a
+ No LSB modules are available.
+ Distributor ID: Ubuntu
+ Description: Ubuntu 16.04.2 LTS
+ Release: 16.04
+ Codename: xenial
+
+ $ lsb_release -a
+ No LSB modules are available.
+ Distributor ID: Ubuntu
+ Description: Ubuntu 14.04.6 LTS
+ Release: 14.06
+ Codename: trusty
+
+* cat /etc/issue (适合Linux发行版)
+
+ $ cat /etc/issue
+ Ubuntu 16.04.2 LTS \n \l
+
+* cat /etc/redhat-release 只适合Redhat系的Linux
+
diff --git a/linux-quick-start/SUMMARY.md b/linux-quick-start/SUMMARY.md
new file mode 100644
index 0000000..0fbb5a8
--- /dev/null
+++ b/linux-quick-start/SUMMARY.md
@@ -0,0 +1 @@
+SUMMARY.md
\ No newline at end of file
diff --git a/linux-quick-start/common-linux-commands.md b/linux-quick-start/common-linux-commands.md
new file mode 100644
index 0000000..fae4e54
--- /dev/null
+++ b/linux-quick-start/common-linux-commands.md
@@ -0,0 +1,207 @@
+Common.Linux.Commands.md
+
+常用的Linux命令
+
+
+kill -- terminate or signal a process
+
+Some of the more commonly used signals:
+ 1 HUP (hang up)
+ 2 INT (interrupt)
+ 3 QUIT (quit)
+ 6 ABRT (abort)
+ 9 KILL (non-catchable, non-ignorable kill)
+ 14 ALRM (alarm clock)
+ 15 TERM (software termination signal)
+cd
+
+* ls
+
+ ls -al
+ ls -alh
+
+* 检查文件系统的磁盘空间占用情况 df
+
+ $ df -h
+ Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
+ /dev/disk2 1.0Ti 348Gi 681Gi 34% 5524742 4289442537 0% /
+ devfs 191Ki 191Ki 0Bi 100% 661 0 100% /dev
+ map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
+ map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
+
+* 查询目录文件的磁盘使用空间 du
+
+ // 查看当前目录下的大小
+ $ du -sh
+ 355M .
+
+ // 查看指定目录 vendor 的大小
+ $ du -sh vendor
+ 46M vendor
+
+ // 安装文件大小排序
+ $ du ./app/ | sort -nr | more
+
+
+wget
+
+curl
+
+
+
+## 压缩与解压
+
+.tar.gz
+格式解压为 tar -zxvf xx.tar.gz
+
+.tar.bz2
+格式解压为 tar -jxvf xx.tar.bz2
+
+解压
+tar –xvf file.tar //解压 tar包
+tar -xzvf file.tar.gz //解压tar.gz
+tar -xjvf file.tar.bz2 //解压 tar.bz2
+tar –xZvf file.tar.Z //解压tar.Z
+unrar e file.rar //解压rar
+unzip file.zip //解压zip
+
+unzip accounts.zip
+gunzip logs.jsonl.gz
+
+
+
+grep
+
+ps -ef |grep nginx
+
+文件权限:
+
+使用chown命令来改变文件所有者。chown命令是change owner(改变拥有者)的缩写
+chown [-R] 账号名称 文件或目录
+chown [-R] 账号名称:用户组名称 文件或目录
+
+使用chgrp命令来改变文件所属用户组,该命令就是change group(改变用户组)的缩写:
+chgrp [-R] 用户组名称 dirname/filename
+
+chmod(变动文件属性)
+文件属性的设置方式有两种,,别离是数字和标记。
+
+
+find ~ -name "*.txt" -print #在$HOME中查.txt文件并显示
+
+查看文件中的内容,显示其上下各3行:
+$ cat ~/orp/webserver/conf/nginx.conf |grep -3 8248
+
+添加所有的新增文件到SVN中
+```
+svn st | grep '^\?' | tr '^\?' ' ' | sed 's/[ ]*//' | sed 's/[ ]/\\ /g' | xargs svn add
+
+svn st | awk '{if ( $1 == "?") { print $2}}' | xargs svn add
+```
+
+$ svn up --username wangyongtao --password 123456
+
+
+```
+//分行显示sql备份文件
+perl -p -i -e "s/\),\(/\r\n/g" tb_channel.sql
+```
+
+
+
+### 简单的WEB服务器
+
+* Ptyhon: SimpleHTTPServer
+
+可以使用http://[IP地址]:8001/来访问web页面或共享文件
+
+ ```
+ //http://127.0.0.1:8000/
+ $ sudo python -m SimpleHTTPServer 8001
+ ```
+
+* PHP 内置的Web服务器
+
+PHP: 从5.4.0起, CLI SAPI 提供了一个内置的Web服务器
+
+ ```
+ //启动Web服务器,当前目录
+ $ php -S localhost:8000
+
+ //指定目录 -t
+ $ php -S localhost:8000 -t foo/
+
+ //指定目录,可以通过ip远程访问
+ $ php -S 0.0.0.0:8080:8000 -t foo/
+ ```
+
+
+### 在Mac中,在命令行中用sublime打开文件
+
+//打开当前文件夹:
+$ /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl ./
+
+为Sublime做个软连接:
+$ ls /Applications |grep "Sublime"
+Sublime Text 2.app
+Sublime Text.app (这个是Sublime Text 3)
+
+//比如为Sublime Text 2.app做软件接:
+$ sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
+//比如为Sublime Text.app做软件接:
+$ sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
+$ /usr/local/bin/sublime ./
+$ sublime ./
+
+
+* [dos2unix / unix2dos]
+
+使用dos2unix, unix2dos 命令实现 DOS <=> UNIX text file 转换
+
+ dos2unix 将 Windows 文件格式(\r\n) 转换为 Unix/Linux 文件格式(\n)。
+ unix2dos 将 Unix/Linux 文件格式(\n)转换为 DOS/Windows 文件格式(\r\n)。
+
+ UNIX/Linux 使用 `0x0A`(LF)作为换行符(\n); DOS/Windows 使用 `0x0D0A`(CRLF)作为换行符 (\r\n).
+
+
+| Command | Description |
+| ---------------------------------- | ---------------------------------------- |
+| cat [filename] | Display file’s contents to the standard output device(usually your monitor). |
+| cd /directorypath | Change to directory. |
+| chmod [options] mode filename | Change a file’s permissions. |
+| chown [options] filename | Change who owns a file. |
+| clear | Clear a command line screen/window for a fresh start. |
+| cp [options] source destination | Copy files and directories. |
+| date [options] | Display or set the system date and time. |
+| df [options] | Display used and available disk space. |
+| du [options] | Show how much space each file takes up. |
+| file [options] filename | Determine what type of data is within a file. |
+| find [pathname] [expression] | Search for files matching a provided pattern. |
+| grep [options] pattern [filesname] | Search files or output for a particular pattern. |
+| kill [options] pid | Stop a process. If the process refuses to stop, use kill -9 pid. |
+| less [options] [filename] | View the contents of a file one page at a time. |
+| ln [options] source [destination] | Create a shortcut. |
+| locate filename | Search a copy of your filesystem for the specifiedfilename. |
+| lpr [options] | Send a print job. |
+| ls [options] | List directory contents. |
+| man [command] | Display the help information for the specified command. |
+| mkdir [options] directory | Create a new directory. |
+| mv [options] source destination | Rename or move file(s) or directories. |
+| passwd [name [password]] | Change the password or allow (for the system administrator) tochange any password. |
+| ps [options] | Display a snapshot of the currently running processes. |
+| pwd | Display the pathname for the current directory. |
+| rm [options] directory | Remove (delete) file(s) and/or directories. |
+| rmdir [options] directory | Delete empty directories. |
+| ssh [options] user@machine | Remotely login to another Linux machine.Leave an ssh session by typing exit. |
+| su [options] [user [arguments]] | Switch to another user account. |
+| tail [options] [filename] | Display the last *n* lines of a file (the default is10). |
+| tar [options] filename | Store and extract files from a tarfile (.tar) or tarball (.tar.gz or.tgz). |
+| top | Displays the resources being used on your system. Press q toexit. |
+| touch filename | Create an empty file with the specified name. |
+| who [options] | Display who is logged on. |
+
+-- from [COMMON LINUX COMMANDS](http://www.dummies.com/computers/operating-systems/linux/common-linux-commands/)
+
+
+
+[END]
\ No newline at end of file
diff --git a/linux-quick-start/linux-rsync.md b/linux-quick-start/linux-rsync.md
new file mode 100644
index 0000000..1cbd9db
--- /dev/null
+++ b/linux-quick-start/linux-rsync.md
@@ -0,0 +1 @@
+rsync.md
\ No newline at end of file
diff --git a/linux-quick-start/linux-scp.md b/linux-quick-start/linux-scp.md
new file mode 100644
index 0000000..a4d77ea
--- /dev/null
+++ b/linux-quick-start/linux-scp.md
@@ -0,0 +1,37 @@
+linux-command-scp.md
+
+scp -- secure copy (remote file copy program)
+
+
+* 上传文件到远程服务器:
+
+```
+// 默认
+$ scp ~/demo/homestead_2017-06-12.sql root@wang123.net:/wwwdata/demo/
+
+// 指定端口号,并重命名文件
+$ scp -P 123456 ~/demo/homestead_2017-06-12.sql root@wang123.net:/wwwdata/demo/homestead.sql
+```
+
+scp -P 2233 root@106.14.34.47:/tmp/test.txt ./test111.txt
+
+
+* 从远程服务器下载文件:
+
+```
+// 默认: 下载文件到 `~/demo/` 目录中
+$ scp root@wang123.net:/wwwdata/demo/homestead.sql ~/demo/
+
+// 指定端口号,并重命名文件
+$ scp -P 123456 root@wang123.net:/wwwdata/demo/homestead.sql ~/demo/homestead_20170620.sql
+```
+
+常用参数:
+
+
+`-r`: Recursively copy entire directories. 递归拷贝(拷贝目录)
+`-P`: Specifies the port to connect to on the remote host. 指定远程服务器的端口号
+`-v`: Verbose mode. 显示进度. 可用来查看连接、认证或是配置问题
+
+
+
diff --git a/linux-quick-start/linux-shell.md b/linux-quick-start/linux-shell.md
new file mode 100644
index 0000000..3ff9d7e
--- /dev/null
+++ b/linux-quick-start/linux-shell.md
@@ -0,0 +1,169 @@
+
+# Linux Shell
+
+$ vi hello.sh
+
+```
+#!/bin/bash
+echo "Hello World !"
+```
+
+执行脚本:
+
+
+$ sh hello.sh
+Hello World !
+
+$ chmod +x hello.sh
+$ demo ./hello.sh
+Hello World !
+
+
+定义变量时,变量名不加美元符号($),变量名和等号之间不能有空格, 如:
+
+```
+Name="WANGYT"
+```
+
+使用一个定义过的变量,只要在变量名前面加美元符号($)即可,如:
+
+```
+Name="WANGYT"
+echo $Name
+echo ${Name}
+```
+
+字符串
+
+字符串可以用单引号,也可以用双引号,也可以不用引号。
+
+单引号:
+
+单引号里的任何字符都会原样输出,单引号字符串中的变量是无效的;
+单引号字串中不能出现单引号(对单引号使用转义符后也不行)。
+
+双引号:
+
+双引号里可以有变量
+双引号里可以出现转义字符
+
+
+拼接字符串
+
+```
+# hello.sh
+Name="Linux Shell"
+str1='str1: hello, $Name !'
+str2="str2: hello, $Name !"
+str3="str3: hello, "$Name" !"
+echo $str1;
+echo $str2;
+echo $str3;
+```
+
+```
+$ sh hello.sh
+str1: hello, $Name !
+str2: hello, Linux Shell !
+str3: hello, Linux Shell !
+```
+
+获取字符串长度
+
+```
+# 输出结果: 5
+string="nihao"
+echo ${#string}
+```
+
+| 运算符 | 说明 | 举例 |
+| ---- | ----------------------------- | ----------------------- |
+| -eq | 检测两个数是否相等,相等返回 true。 | [ $a -eq $b ] 返回 true。 |
+| -ne | 检测两个数是否相等,不相等返回 true。 | [ $a -ne $b ] 返回 true。 |
+| -gt | 检测左边的数是否大于右边的,如果是,则返回 true。 | [ $a -gt $b ] 返回 false。 |
+| -lt | 检测左边的数是否小于右边的,如果是,则返回 true。 | [ $a -lt $b ] 返回 true。 |
+| -ge | 检测左边的数是否大等于右边的,如果是,则返回 true。 | [ $a -ge $b ] 返回 false。 |
+| -le | 检测左边的数是否小于等于右边的,如果是,则返回 true。 | [ $a -le $b ] 返回 true。 |
+
+文件测试运算符
+
+文件测试运算符用于检测 Unix 文件的各种属性。
+
+| 操作符 | 说明 | 举例 |
+| ------- | ---------------------------------------- | ---------------------- |
+| -b file | 检测是否是块设备文件,如果是,则返回 true。 | [ -b $file ] 返回 false。 |
+| -c file | 检测是否是字符设备文件,如果是,则返回 true。 | [ -b $file ] 返回 false。 |
+| -d file | 检测是否是目录,如果是,则返回 true。 | [ -d $file ] 返回 false。 |
+| -f file | 检测是否是普通文件(非目录、非设备文件),如果是,则返回 true。 | [ -f $file ] 返回 true。 |
+| -g file | 检测是否设置了 SGID 位,如果是,则返回 true。 | [ -g $file ] 返回 false。 |
+| -k file | 检测是否设置了粘着位(Sticky Bit),如果是,则返回 true。 | [ -k $file ] 返回 false。 |
+| -p file | 检测是否是具名管道,如果是,则返回 true。 | [ -p $file ] 返回 false。 |
+| -u file | 检测是否设置了 SUID 位,如果是,则返回 true。 | [ -u $file ] 返回 false。 |
+| -r file | 检测是否可读,如果是,则返回 true。 | [ -r $file ] 返回 true。 |
+| -w file | 检测是否可写,如果是,则返回 true。 | [ -w $file ] 返回 true。 |
+| -x file | 检测是否可执行,如果是,则返回 true。 | [ -x $file ] 返回 true。 |
+| -s file | 检测是否为空(文件大小是否大于0),不为空返回 true。 | [ -s $file ] 返回 true。 |
+| -e file | 检测文件(包括目录)是否存在,如果是,则返回 true。 | [ -e $file ] 返回 true。 |
+
+
+
+if 分支
+
+Shell 有三种 if ... else 语句:
+
+if ... fi 语句
+if ... else ... fi 语句
+if ... elif ... else ... fi 语句
+
+```
+#!/bin/sh
+a=10
+b=20
+
+if [ $a == $b ]
+then
+ echo "=> a is equal to b"
+fi
+
+if [ $a != $b ]
+then
+ echo "=> a is not equal to b"
+fi
+```
+
+```
+#!/bin/sh
+a=10
+b=20
+if [ $a == $b ]
+then
+ echo "=> a is equal to b"
+else
+ echo "=> a is not equal to b"
+fi
+```
+
+```
+#!/bin/sh
+a=10
+b=20
+if [ $a == $b ]
+then
+ echo "a is equal to b"
+elif [ $a -gt $b ]
+then
+ echo "a is greater than b"
+elif [ $a -lt $b ]
+then
+ echo "a is less than b"
+else
+ echo "None of the condition met"
+fi
+```
+
+Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值、字符和文件三个方面的测试。
+
+DATE=`date "+%Y-%m-%d %T"`
+
+DATE=`date "+%Y-%m-%d %H:%M:%S"`;
+
diff --git a/linux-quick-start/linux-tar-zip.md b/linux-quick-start/linux-tar-zip.md
new file mode 100644
index 0000000..b952485
--- /dev/null
+++ b/linux-quick-start/linux-tar-zip.md
@@ -0,0 +1,63 @@
+linux-command-压缩与解压.md
+
+## 压缩与解压
+
+.tar.gz
+格式解压为 tar -zxvf xx.tar.gz
+
+.tar.bz2
+格式解压为 tar -jxvf xx.tar.bz2
+
+解压
+tar –xvf file.tar //解压 tar包
+tar -xzvf file.tar.gz //解压tar.gz
+tar -xjvf file.tar.bz2 //解压 tar.bz2
+tar –xZvf file.tar.Z //解压tar.Z
+unrar e file.rar //解压rar
+unzip file.zip //解压zip
+
+unzip accounts.zip
+gunzip logs.jsonl.gz
+
+根据php官网下载地址,可以看到目前提供了三种下载格式:
+
+
+http://php.net/downloads.php
+
+* php-7.1.4.tar.bz2 (sig) [15,343Kb] 13 Apr 2017
+
+* php-7.1.4.tar.gz (sig) [19,843Kb] 13 Apr 2017
+
+* php-7.1.4.tar.xz (sig) [12,494Kb] 13 Apr 2017
+
+```
+$ ls -al
+total 95368
+drwxr-xr-x 5 WangTom staff 170 5 3 11:06 .
+drwxr-xr-x 6 WangTom staff 204 5 3 11:06 ..
+-rw-r-----@ 1 WangTom staff 15710808 5 3 11:03 php-7.1.4.tar.bz2
+-rw-r-----@ 1 WangTom staff 20319716 5 3 11:04 php-7.1.4.tar.gz
+-rw-r-----@ 1 WangTom staff 12793840 5 3 11:03 php-7.1.4.tar.xz
+```
+
+tar.xz 文件最小
+tar.bz2 文件最小
+tar.xz 文件最小
+
+// 解压 tar.bz2
+
+```
+$ tar -xjf php-7.1.4.tar.bz2
+```
+
+//解压 tar.gz
+
+```
+$ tar -xzf php-7.1.4.tar.gz
+```
+
+//解压 tar.xz
+
+```
+$ tar -xzf php-7.1.4.tar.xz
+```
\ No newline at end of file
diff --git a/open-source-licenses.md b/open-source-licenses.md
new file mode 100644
index 0000000..51e7a9b
--- /dev/null
+++ b/open-source-licenses.md
@@ -0,0 +1,41 @@
+
+open-source-licenses
+
+
+通用性公开许可证(General Public License,简称GPL)
+
+
+MPL (Mozilla Public License) 许可证
+
+MIT 许可证
+
+https://mit-license.org/
+
+https://opensource.org/licenses/mit-license.php
+
+
+Apache Licene 2.0 许可证
+
+Apache License Version 2.0, January 2004
+
+https://www.apache.org/licenses/LICENSE-2.0
+https://opensource.org/licenses/Apache-2.0
+
+LGPL 许可证
+
+GPL 许可证
+
+BSD 许可证
+
+Mozilla Public License 2.0 (MPL-2.0)
+
+https://opensource.org/licenses/MPL-2.0
+
+
+Creative Commons licenses
+
+https://creativecommons.org/licenses/?lang=zh
+
+MIT是和BSD一样宽松的许可协议,作者只想保留版权,而无任何其他了限制
+
+
diff --git a/php-quick-start/php-string.md b/php-quick-start/php-string.md
new file mode 100644
index 0000000..cfe5898
--- /dev/null
+++ b/php-quick-start/php-string.md
@@ -0,0 +1 @@
+php-string.md
\ No newline at end of file
diff --git a/php-swagger.md b/php-swagger.md
new file mode 100644
index 0000000..d7d51a2
--- /dev/null
+++ b/php-swagger.md
@@ -0,0 +1,21 @@
+php-swagger
+
+
+
+[swagger-php](https://github.com/zircote/swagger-php)
+
+Installation (with Composer)
+
+ composer require zircote/swagger-php
+ composer global require zircote/swagger-php
+
+
+ ~/.composer/vendor/bin/swagger --help
+
+
+
+
+
+ git clone https://github.com/swagger-api/swagger-ui
+
+
\ No newline at end of file
diff --git a/posts/HTTPS-Lets-Encrypt-SSL-demo.md b/posts/HTTPS-Lets-Encrypt-SSL-demo.md
new file mode 100644
index 0000000..6424979
--- /dev/null
+++ b/posts/HTTPS-Lets-Encrypt-SSL-demo.md
@@ -0,0 +1,83 @@
+HTTPS-Lets-Encrypt-SSL-demo.md
+
+
+Certbot, previously the Let's Encrypt Client, is EFF's tool to obtain certs from Let's Encrypt,
+and (optionally) auto-enable HTTPS on your server.
+It can also act as a client for any other CA that uses the ACME protocol.
+
+
+$ wget https://github.com/certbot/certbot/archive/v0.12.0.tar.gz
+
+$ ./certbot-auto certonly
+
+Saving debug log to /var/log/letsencrypt/letsencrypt.log
+
+How would you like to authenticate with the ACME CA?
+-------------------------------------------------------------------------------
+1: Apache Web Server plugin - Beta (apache)
+2: Place files in webroot directory (webroot)
+3: Spin up a temporary webserver (standalone)
+-------------------------------------------------------------------------------
+Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 2
+
+worker_processes 1;
+Please enter in your domain name(s) (comma and/or space separated) (Enter 'c'
+to cancel):wang123.net
+Obtaining a new certificate
+Performing the following challenges:
+http-01 challenge for wang123.net
+
+Select the webroot for wang123.net:
+-------------------------------------------------------------------------------
+1: Enter a new webroot
+-------------------------------------------------------------------------------
+Press 1 [enter] to confirm the selection (press 'c' to cancel): 1
+Input the webroot for wang123.net: (Enter 'c' to cancel):/wwwdata/wwwroot/wang123net/public/
+Waiting for verification...
+Cleaning up challenges
+Generating key (2048 bits): /etc/letsencrypt/keys/0000_key-certbot.pem
+Creating CSR: /etc/letsencrypt/csr/0000_csr-certbot.pem
+
+IMPORTANT NOTES:
+ - Congratulations! Your certificate and chain have been saved at
+ /etc/letsencrypt/live/wang123.net/fullchain.pem. Your cert will
+ expire on 2017-06-30. To obtain a new or tweaked version of this
+ certificate in the future, simply run certbot-auto again. To
+ non-interactively renew *all* of your certificates, run
+ "certbot-auto renew"
+ - If you like Certbot, please consider supporting our work by:
+
+ Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
+ Donating to EFF: https://eff.org/donate-le
+
+$ cd /etc/letsencrypt/live/wang123.net
+$ ls
+README cert.pem chain.pem fullchain.pem privkey.pem
+
+
+```
+# HTTPS server
+server {
+ listen 443 ssl;
+ server_name wang123.net;
+
+ ssl_certificate /etc/letsencrypt/live/wang123.net/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/wang123.net/privkey.pem;
+
+ ssl_session_cache shared:SSL:1m;
+ ssl_session_timeout 5m;
+
+ ssl_ciphers HIGH:!aNULL:!MD5;
+ ssl_prefer_server_ciphers on;
+
+ location / {
+ root html;
+ index index.html index.htm;
+ }
+}
+```
+
+
+https://github.com/certbot/certbot
+
+https://certbot.eff.org/
\ No newline at end of file
diff --git a/posts/READMET.md b/posts/READMET.md
new file mode 100644
index 0000000..b93012f
--- /dev/null
+++ b/posts/READMET.md
@@ -0,0 +1,5 @@
+### POSTS
+
+* [HTTPS-Lets-Encrypt-SSL-demo](HTTPS-Lets-Encrypt-SSL-demo.md)
+
+* [Lumen / Laravel 5.4 使用网易邮箱 SMTP 发送邮件](laravel-5.4-send-mail-demo.md)
diff --git a/posts/Ubuntu-Homestead-Install-PHP5.5.md b/posts/Ubuntu-Homestead-Install-PHP5.5.md
new file mode 100644
index 0000000..6fe9885
--- /dev/null
+++ b/posts/Ubuntu-Homestead-Install-PHP5.5.md
@@ -0,0 +1,324 @@
+安装php-5.5环境
+
+
+> Laravel Homestead 是一个官方预载的 Vagrant「封装包」,提供你一个美好的开发环境,不需要在本机端安装 PHP、HHVM、网页服务器或任何服务器软件。
+> Homestead 可以在任何 Windows、Mac 或 Linux 上面运行,里面包含了 Nginx 网页服务器、PHP 5.6、MySQL、Postgres、Redis、Memcached等软件,
+> 还有所有你要开发精彩的 Laravel 应用程序所需的软件。
+
+目前,使用最新的 Laravel - Homestead, 安装的PHP版本是7.1.
+
+由于某些原因,我们需要在Vagrant虚拟机中,额外安装php5.5以及phpredis扩展,现记录如下。
+
+$ cd ~/Homestead
+$ vagrant ssh
+
+进入vagrant 虚拟机中
+
+创建`/usr/local/webserver/` 目录:
+
+下载地址: http://cn2.php.net/releases/
+选择: php-5.5.38
+
+
+$ sudo ./configure \
+ --prefix=/usr/local/webserver/php55 \
+ --with-config-file-path=/usr/local/webserver/php55 \
+ --with-mysql \
+ --with-mysqli \
+ --enable-pdo \
+ --with-pdo-mysql \
+ --enable-cgi \
+ --enable-fpm \
+ --enable-sockets \
+ --enable-mbstring \
+ --enable-mbregex \
+ --enable-bcmath \
+ --enable-xml \
+ --enable-zip \
+ --with-gd
+
+$ sudo make
+
+vagrant@homestead:/usr/local/webserver/php-5.5.38$ sudo make install
+Installing shared extensions: /usr/local/webserver/php55/lib/php/extensions/no-debug-non-zts-20121212/
+Installing PHP CLI binary: /usr/local/webserver/php55/bin/
+Installing PHP CLI man page: /usr/local/webserver/php55/php/man/man1/
+Installing PHP FPM binary: /usr/local/webserver/php55/sbin/
+Installing PHP FPM config: /usr/local/webserver/php55/etc/
+Installing PHP FPM man page: /usr/local/webserver/php55/php/man/man8/
+Installing PHP FPM status page: /usr/local/webserver/php55/php/php/fpm/
+Installing PHP CGI binary: /usr/local/webserver/php55/bin/
+Installing PHP CGI man page: /usr/local/webserver/php55/php/man/man1/
+Installing build environment: /usr/local/webserver/php55/lib/php/build/
+Installing header files: /usr/local/webserver/php55/include/php/
+Installing helper programs: /usr/local/webserver/php55/bin/
+ program: phpize
+ program: php-config
+Installing man pages: /usr/local/webserver/php55/php/man/man1/
+ page: phpize.1
+ page: php-config.1
+Installing PEAR environment: /usr/local/webserver/php55/lib/php/
+[PEAR] Archive_Tar - installed: 1.4.0
+[PEAR] Console_Getopt - installed: 1.4.1
+[PEAR] Structures_Graph- installed: 1.1.1
+[PEAR] XML_Util - installed: 1.3.0
+[PEAR] PEAR - installed: 1.10.1
+Wrote PEAR system config file at: /usr/local/webserver/php55/etc/pear.conf
+You may want to add: /usr/local/webserver/php55/lib/php to your php.ini include_path
+/usr/local/webserver/php-5.5.38/build/shtool install -c ext/phar/phar.phar /usr/local/webserver/php55/bin
+ln -s -f phar.phar /usr/local/webserver/php55/bin/phar
+Installing PDO headers: /usr/local/webserver/php55/include/php/ext/pdo/
+
+
+通过命令行,查看版本:
+
+```
+$ /usr/local/webserver/php55/bin/php -v
+PHP 5.5.38 (cli) (built: Apr 5 2017 08:25:03)
+Copyright (c) 1997-2015 The PHP Group
+Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
+```
+
+```
+$ sudo ln -s /usr/local/webserver/php55/bin/php /usr/local/bin/php55
+
+$ php55 --version
+PHP 5.5.38 (cli) (built: Apr 5 2017 08:25:03)
+Copyright (c) 1997-2015 The PHP Group
+Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
+
+$ php --version
+PHP 7.0.8-2+deb.sury.org~xenial+1 (cli) ( NTS )
+Copyright (c) 1997-2016 The PHP Group
+Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
+```
+
+
+## 配置FPM:
+
+FastCGI进程管理器(FPM),编译 PHP 时需要 --enable-fpm 配置选项来激活 FPM 支持。此选项在本次在编译时已经加上了。
+
+进入 `php55/etc/` 目录,复制一份配置`php-fpm.conf`:
+
+```
+$ cd /usr/local/webserver/php55/etc/
+$ sudo cp php-fpm.conf.default php-fpm.conf
+```
+
+测试FPM的配置文件是否正确
+
+```
+$ sudo /usr/local/webserver/php55/sbin/php-fpm -t
+[05-Apr-2017 08:52:37] NOTICE: configuration file /usr/local/webserver/php55/etc/php-fpm.conf test is successful
+```
+
+启动 `php-fpm`:
+$ sudo /usr/local/webserver/php55/sbin/php-fpm
+
+$ sudo /usr/local/webserver/php55/sbin/php-fpm
+[05-Apr-2017 08:54:05] ERROR: [pool www] cannot get gid for group 'nobody'
+[05-Apr-2017 08:54:05] ERROR: FPM initialization failed
+
+
+$ sudo groupadd nobody
+
+$ sudo /usr/local/webserver/php55/sbin/php-fpm
+[05-Apr-2017 08:55:03] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
+[05-Apr-2017 08:55:03] ERROR: FPM initialization failed
+
+
+//可以修改FPM配置文件中的日志路径及监听端口:
+$ sudo vi /usr/local/webserver/php55/etc/php-fpm.conf
+
+
+修改FPM配置文件:(注释使用英文分号)
+
+> 配置文件路径: /usr/local/webserver/php54/etc/php-fpm.conf
+> ;//error_log = log/php-fpm.log (默认的地址)
+> error_log = /usr/local/webserver/php54/var/log/php-fpm.log
+>
+> // 比如可以将9000端口改成9001:
+> ;listen = 127.0.0.1:9000
+> listen = 127.0.0.1:9055
+
+
+创建 Nginx 配置文件:
+
+sudo vi /etc/nginx/conf.d/adminlocal.boqii.com.conf
+
+注意: 如果此处的FPM端口号要和 `php-fpm.conf` 中配置的相同:
+ Nginx配置文件: /usr/local/webserver/nginx/nginc.conf
+ `fastcgi_pass 127.0.0.1:9055;`
+
+
+完整的配置如下
+
+```
+server {
+ listen 80;
+ server_name adminlocal.boqii.com;
+ root "/home/vagrant/Code/admin";
+
+ index index.html index.htm index.php;
+
+ charset utf-8;
+
+ location / {
+
+ if ($request_method = 'OPTIONS') {
+ add_header Access-Control-Allow-Origin *;
+ add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
+ add_header Access-Control-Allow-Headers Content-Type,app-id,signature,timestamp,nonce,Authorization;
+ add_header Allow OPTIONS,HEAD,DELETE,POST,GET;
+ return 204;
+ }
+
+ try_files $uri $uri/ /index.php?$query_string;
+ }
+
+ location = /favicon.ico { access_log off; log_not_found off; }
+ location = /robots.txt { access_log off; log_not_found off; }
+
+ access_log off;
+ error_log /var/log/nginx/adminlocal.boqii.com-error.log error;
+
+ sendfile off;
+
+ client_max_body_size 100m;
+
+ location ~ \.php$ {
+ add_header Access-Control-Allow-Origin *;
+ add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
+ add_header Access-Control-Allow-Headers Content-Type,app-id,signature,timestamp.nonce,Authorization;
+ add_header Allow OPTIONS,HEAD,DELETE,POST,GET;
+
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
+ fastcgi_pass 127.0.0.1:9055;
+ fastcgi_index index.php;
+ include fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+ fastcgi_intercept_errors off;
+ fastcgi_buffer_size 16k;
+ fastcgi_buffers 4 16k;
+ fastcgi_connect_timeout 300;
+ fastcgi_send_timeout 300;
+ fastcgi_read_timeout 300;
+ }
+}
+```
+
+
+## 安装PhpRedis扩展
+
+
+PhpRedis, 是用C语言编写的PHP模块,用来连接并操作Redis数据库。
+
+The phpredis extension provides an API for communicating with the Redis key-value store.
+
+网址: https://github.com/phpredis/phpredis
+代码: https://github.com/phpredis/phpredis/releases
+本次下载的版本: phpredis-2.2.7.tar.gz
+
+```
+$ sudo wget https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz
+$ tar zxvf 3.1.2.tar.gz
+$ cd phpredis-3.1.2
+$ sudo /usr/local/webserver/php55/bin/phpize
+ Configuring for:
+ PHP Api Version: 20121113
+ Zend Module Api No: 20121212
+ Zend Extension Api No: 220121212
+
+$ sudo ./configure --with-php-config=/usr/local/webserver/php55/bin/php-config
+$ sudo make
+$ sudo make test
+$ sudo make install
+Installing shared extensions: /usr/local/webserver/php55/lib/php/extensions/no-debug-non-zts-20121212/
+
+```
+
+注意redis.so扩展的路径:
+/usr/local/webserver/php55/lib/php/extensions/no-debug-non-zts-20121212/
+
+
+修改php.ini配置文件,指定redis.so文件路径:
+
+```
+ extension=redis.so
+
+```
+
+如果在php55目录中,没有发现有 php.ini 文件,那就去 php 源码中复制一份:
+
+```
+$ cd /usr/local/webserver/php55
+
+$ php55 -i | grep php.ini
+Configuration File (php.ini) Path => /usr/local/webserver/php55
+
+$ find /usr/local/webserver/ -name 'php.ini*'
+/usr/local/webserver/php-5.5.38/php.ini-development
+/usr/local/webserver/php-5.5.38/php.ini-production
+
+$ sudo cp /usr/local/webserver/php-5.5.38/php.ini-development /usr/local/webserver/php55/php.ini
+```
+
+如果不写绝对地址,需要做个软连接,否则可能会出错:
+
+```
+ extension=redis.so
+
+ 或者:
+ extension=/usr/local/webserver/php55/lib/php/extensions/no-debug-non-zts-20100525/redis.so
+```
+
+注意:如果不想写全路径,可以执行以下命令,做个软连接:
+
+sudo ln -s ln -s /usr/local/webserver/php55/lib/php/extensions/no-debug-non-zts-20121212/redis.so redis.so
+
+
+
+
+查看已安装扩展(命令行):
+
+```
+// 可以使用 `-m` 参数来列出所有有效的扩展
+$ /usr/local/webserver/php55/bin/php -m |grep redis
+redis
+```
+
+
+### 扩展阅读
+
+(1) brew
+
+brew(即Homebrew), 是macOS上的软件包管理工具, 能在Mac中方便的安装软件或者卸载软件,类似ubuntu系统下的apt-get的功能.
+Homebrew- The missing package manager for OS X
+http://brew.sh/
+
+(2) Vagrant
+
+Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境。它使用Oracle的开源VirtualBox虚拟化系统,使用Chef创建自动化虚拟环境。
+https://www.vagrantup.com/
+
+(3) Laravel
+
+Laravel是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。
+https://laravel.com/
+
+(4) PHP5 与 PHP7
+
+PHP 是一种非常流行的服务器端脚本语言,主要适用于Web开发领域。
+2004年7月,PHP 5.0版本正式发布,目前最新为 PHP 5.6.30 (19 Jan 2017).
+2015年12月,PHP 7.0版本正式发布, 目前最新为 PHP7.1.3 (16 Mar 2017).
+http://php.net/
+
+
+
+
+
+
+
+
+
diff --git a/posts/laravel-5.4-send-mail-demo.md b/posts/laravel-5.4-send-mail-demo.md
new file mode 100644
index 0000000..837f2cc
--- /dev/null
+++ b/posts/laravel-5.4-send-mail-demo.md
@@ -0,0 +1,217 @@
+Lumen / Laravel 5.4 使用网易邮箱 SMTP 发送邮件
+
+
+## 获取网易邮箱的服务器和授权码:
+
+登录网易邮箱 (http://mail.163.com/),
+
+* 1. 获取服务器地址:
+点击【设置】 > 【POP3/SMTP/IMAP】:
+
+服务器地址:
+```
+ POP3服务器: pop.163.com
+ SMTP服务器: smtp.163.com
+ IMAP服务器: imap.163.com
+```
+
+* 2. 获取客户端授权密码
+
+> 授权码
+> 授权码是用于登录第三方邮件客户端的专用密码。
+> 适用于登录以下服务: POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务。
+
+点击【设置】 > 【客户端授权密码】
+点击【开启】, 设置一个授权码, 比如本例中将授权码设置为: `mailPASSWORD`
+
+
+## 配置 env 文件:
+
+在配置文件 `.env`文件,新增以下配置:
+
+```
+MAIL_DRIVER=smtp
+MAIL_HOST=smtp.163.com
+MAIL_PORT=25
+MAIL_USERNAME=cnwytnet@163.com
+MAIL_PASSWORD=mailPASSWORD
+MAIL_ENCRYPTION=null
+MAIL_FROM_ADDRESS=cnwytnet@163.com
+MAIL_FROM_NAME=cnwytnet
+```
+
+## Lumen 项目
+
+由于 Lumen 是简化版的 Laravel, 需要增加以下发邮件的模块。
+
+* 需要添加 `illuminate/mail` 模块:
+
+修改`composer.json` 文件中 require 部分配置如下:
+
+```
+ "require": {
+ "php": ">=5.6.9",
+ "laravel/lumen-framework": "5.4.*",
+ "vlucas/phpdotenv": "~2.2",
+ "guzzlehttp/guzzle": "^6.2",
+ "predis/predis": "^1.1",
+ "illuminate/redis": "^5.4",
+ "illuminate/mail":"5.4.*"
+ }
+```
+
+执行 `composer up`.
+
+* 需要增加mail.php配置文件:
+
+确保Luemn项目中存在 `app/config/mail.php` 配置文件。
+若不存在可以从 Laravel 代码中复制一份, 或者新建一份,示例如下:
+
+```
+ env('MAIL_DRIVER', 'smtp'),
+ 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
+ 'port' => env('MAIL_PORT', 587),
+ 'from' => [
+ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
+ 'name' => env('MAIL_FROM_NAME', 'Example'),
+ ],
+ 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
+ 'username' => env('MAIL_USERNAME'),
+ 'password' => env('MAIL_PASSWORD'),
+ 'sendmail' => '/usr/sbin/sendmail -bs',
+ 'markdown' => [
+ 'theme' => 'default',
+ 'paths' => [
+ resource_path('views/vendor/mail'),
+ ],
+ ],
+];
+```
+
+
+## 创建发邮件脚本
+
+* 创建脚本文件 `app/Console/Command/SendMailCommand.php`
+
+```
+subject('[ 测试 ] 测试邮件SendMail - ' .date('Y-m-d H:i:s'));
+ $message->to($toMail);
+ });
+ }
+}
+```
+
+* 将脚本文件加入到 app/Console/Kernel.php 中:
+
+```
+ protected $commands = [
+ Commands\SendMailCommand::class, //测试发邮件脚本
+ ];
+```
+
+## 执行发邮件操作
+
+* 查看脚本, 可以看到我们新加的脚本命令 `demo:SendMail`:
+
+```
+$ php artisan
+demo
+ demo:SendMail 命令行-测试脚本-SendMail
+```
+
+* 执行发送邮件脚本:
+
+```
+$ php artisan demo:SendMail
+```
+
+不出意外的话,邮件发送成功。查看发件人的发件箱,或者查看收件人的收件箱,确认一下吧。
+
+
+## 其他
+
+* 邮件地址 `MAIL_FROM_ADDRESS` 必须和 `MAIL_USERNAME`一致,否则报错:
+
+```
+ [Swift_TransportException]
+ Expected response code 250 but got code "553", with message "553 Mail from must equal authorized user"
+```
+
+* 不填授权码 `MAIL_PASSWORD` 或者 `MAIL_PASSWORD` 错误,报错:
+
+```
+ [Swift_TransportException]
+ Failed to authenticate on SMTP server with username "cnwytnet@163.com" using 2 possible authenticators
+```
+
+可以将邮件驱动改成 `MAIL_DRIVER=log`, 就可以在本地日志中看到邮件内容了,这在测试的时候会很有用。
+
+比如,在配置`.env`中,修改邮件驱动为`MAIL_DRIVER=log`,将会把邮件发送内容保存到 `storage/logs/laravel.log` 中。
+内容如下:
+
+```
+[2017-04-01 06:12:19] local.DEBUG: Message-ID: <727877e080177bbb349b98a869f5b20f@swift.generated>
+Date: Sat, 01 Apr 2017 06:12:19 +0000
+Subject: [ =?utf-8?Q?=E6=B5=8B=E8=AF=95?= ] SendMail - 2017-04-01 06:12:19
+From: SendMailTEST
+To: wangtom365@qq.com
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: quoted-printable
+
+这是一封来自Laravel的测试邮件.
+
+```
+
+
+END.
+
+## 参考链接:
+
+https://laravel.com/docs/5.4/mail
+
+http://laravelacademy.org/post/1986.html
+