Skip to content

Commit

Permalink
换掉新浪图床
Browse files Browse the repository at this point in the history
  • Loading branch information
wujunze committed Jun 13, 2017
1 parent 5f42a11 commit 46e79c7
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,59 @@ echo string

## Nginx Version
Nginx1.0.10 https://github.com/nginx/nginx/releases/tag/release-1.0.10
![image](https://wx1.sinaimg.cn/large/005LOzcmly1fgimmvpk3sj30mi04p3z9.jpg)
![nginx1.0.10.png](https://ooo.0o0.ooo/2017/06/13/593fc07b90e28.png)

## The development environment configuration
```shell
OS : CentOS Linux release 7.2.1511 (Core)
```
![image](https://wx4.sinaimg.cn/large/005LOzcmly1fgimnlvhh0j30s106imxw.jpg)
![image](https://wx4.sinaimg.cn/large/005LOzcmly1fgimnlwy1fj315u0dwdhn.jpg)
![Server_info.png](https://ooo.0o0.ooo/2017/06/13/593fc07b5dff4.png)
![Server_CPU_info.png](https://ooo.0o0.ooo/2017/06/13/593fc0825053e.png)

## Install a clean compile Nginx
1. Download a Nginx10.10 and unpack it
![image](http://wx2.sinaimg.cn/large/005LOzcmly1fgimq77ahwj30pw05et9n.jpg)
![nginx1.0.10.png](https://ooo.0o0.ooo/2017/06/13/593fc07cd07e2.png)

2. Install the GCC and the lib Nginx need
![image](https://wx4.sinaimg.cn/large/005LOzcmly1fgimv0hryoj30pd06djs8.jpg)
![image](https://wx4.sinaimg.cn/large/005LOzcmly1fgimva84bbj30pa07fgms.jpg)
![install_GCC.png](https://ooo.0o0.ooo/2017/06/13/593fc06152dd0.png)
![Nginx_lib.png](https://ooo.0o0.ooo/2017/06/13/593fc078c3c2b.png)

3. ./configure --prefix=/usr/local/nginx && make && make install
![image](https://ws2.sinaimg.cn/large/005LOzcmly1fgimvz2rfkj30j10av75w.jpg)
![image](https://wx2.sinaimg.cn/large/005LOzcmly1fgimw6cmh2j30ur06n757.jpg)
![image](https://ws4.sinaimg.cn/large/005LOzcmly1fgimwezp9tj30qu0fdn0a.jpg)
![configure_ok.png](https://ooo.0o0.ooo/2017/06/13/593fc061b5a9f.png)
![make && make install.png](https://ooo.0o0.ooo/2017/06/13/593fc074c9b29.png)
![nginx_install_ok.png](https://ooo.0o0.ooo/2017/06/13/593fc080db608.png)

4. Nginx run
![image](https://wx3.sinaimg.cn/large/005LOzcmly1fgimy3dkk5j30rr05ddh5.jpg)
![image](https://ws1.sinaimg.cn/large/005LOzcmly1fgimyc58d3j31vk0qsq9y.jpg)
![start_nginx.png](https://ooo.0o0.ooo/2017/06/13/593fc08044567.png)
![nginx_install_ok.png](https://ooo.0o0.ooo/2017/06/13/593fc080db608.png)

## Definition module configuration structure
```C
typedef struct {
ngx_str_t ed; //该结构体定义在这里 https://github.com/nginx/nginx/blob/master/src/core/ngx_string.h
} ngx_http_echo_loc_conf_t;
```
![image](https://wx2.sinaimg.cn/large/005LOzcmly1fgin4at3rsj30rp04g74r.jpg)
![define_moudle_conf.png](https://ooo.0o0.ooo/2017/06/13/593fc0615456f.png)

#Define Nginx instruction and parameter conversion function
![image](https://wx1.sinaimg.cn/large/005LOzcmly1fgjdis37udj30xj0bktan.jpg)
## Define Nginx instruction and parameter conversion function
![定义指令和参数转化函数.png](https://ooo.0o0.ooo/2017/06/13/593fc0529132f.png)

## definition module Context
1. Define the type of ngx_http_module_t structure variables
![image](https://wx3.sinaimg.cn/large/005LOzcmly1fgjer4wtrxj313u09igo7.jpg)
![定义注入点结构体.png](https://ooo.0o0.ooo/2017/06/13/593fc052953a4.png)
2. Initialize a configuration structure
![image](https://wx1.sinaimg.cn/large/005LOzcmly1fgjerqnq71j30zd08fmyd.jpg)
![初始化一个配置结构体.png](https://ooo.0o0.ooo/2017/06/13/593fc05277601.png)
3. Will the father block configuration information incorporated into this structure Implement the configuration of inheritance
![image](https://wx3.sinaimg.cn/large/005LOzcmly1fgjes12fy5j30ya08qgn7.jpg)
![合并父block的配置信息.png](https://ooo.0o0.ooo/2017/06/13/593fc0528ec4a.png)

## Write the Handler really work part of the module
![image](https://ws2.sinaimg.cn/large/005LOzcmly1fgjfosnvf5j31hy0q6wlb.jpg)
![Nginx模块handler.png](https://ooo.0o0.ooo/2017/06/13/593fc0616a385.png)

## Combination Nginx module
![image](https://ws2.sinaimg.cn/large/005LOzcmly1fgjjo2l11jj31en0g4gq1.jpg)
![组合Nginx Module.png](https://ooo.0o0.ooo/2017/06/13/593fc052aa29a.png)

## Finishing module code According to the Nginx official specification
![image](https://ws2.sinaimg.cn/large/005LOzcmly1fgjnxy9ikvj31yx12jwr3.jpg)
![ok_file.png](https://ooo.0o0.ooo/2017/06/13/593fc061b7d7a.png)

## Write the config file
```shell
Expand All @@ -69,18 +70,19 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_echo_module.c"
./configure --prefix=/usr/local/nginx/ --add-module=/root/ngx_dev && make && make install
```
## Successful installation
![image](https://ws3.sinaimg.cn/large/005LOzcmly1fgjnvxyqx4j30w40f0tbw.jpg)
![make install.png](https://ooo.0o0.ooo/2017/06/13/593fc052be07d.png)

## Modify the Nginx configuration file test Module
![image](https://ws2.sinaimg.cn/large/005LOzcmly1fgjnz17rh7j30jl07yaai.jpg)
![test module.png](https://ooo.0o0.ooo/2017/06/13/593fc0614f91a.png)

## Nginx echo Module The successful running
![image](https://ws2.sinaimg.cn/large/005LOzcmly1fgjo0r1a5dj30yf06tmxv.jpg)
![module ok.png](https://ooo.0o0.ooo/2017/06/13/593fc05292b08.png)

# If the repo help you welcome star fork Thanks!

> ## reference
> 1. http://wiki.nginx.org/Configuration
> 2. http://tengine.taobao.org/book/
> 3. **http://blog.codinglabs.org/articles/intro-of-nginx-module-development.html**
> 4. https://www.nginx.com/resources/wiki/modules/
> 4. https://www.nginx.com/resources/wiki/modules/

0 comments on commit 46e79c7

Please sign in to comment.