源码
概述
可以使用yum install tree
来安装tree命令,就可以显示出文件的树结构
可以看出共有10 directories, 265 files,Nginx的主要模块是Core、event、http、mail、misc(杂项,包含多种功能)、os这几个部分,并且根据源代码的命名也可以大致的猜测出其所代表的功能。
[root@iZ94sni08orZ nginx-1.8.0]# tree src/
src/
├── core
│ ├── nginx.c
│ ├── nginx.h
│ ├── ngx_array.c
│ ├── ngx_array.h
│ ├── ngx_buf.c
│ ├── ngx_buf.h
│ ├── ngx_conf_file.c
│ ├── ngx_conf_file.h
│ ├── ngx_config.h
│ ├── ngx_connection.c
│ ├── ngx_connection.h
│ ├── ngx_core.h
│ ├── (省略部分)
│ ├── ngx_times.c
│ └── ngx_times.h
├── event
│ ├── modules
│ │ ├── ngx_aio_module.c
│ │ ├── ngx_devpoll_module.c
│ │ ├── ngx_epoll_module.c
│ │ ├── ngx_eventport_module.c
│ │ ├── ngx_kqueue_module.c
│ │ ├── ngx_poll_module.c
│ │ ├── ngx_rtsig_module.c
│ │ ├── ngx_select_module.c
│ │ └── ngx_win32_select_module.c
│ ├── ngx_event_accept.c
│ ├── ngx_event.c
│ ├── ngx_event_connect.c
│ ├── ngx_event_connect.h
│ ├── (省略部分)
│ └── ngx_event_timer.h
├── http
│ ├── modules
│ │ ├── ngx_http_access_module.c
│ │ ├── ngx_http_addition_filter_module.c
│ │ ├── ngx_http_auth_basic_module.c
│ │ ├── ngx_http_auth_request_module.c
│ │ ├── ngx_http_autoindex_module.c
│ │ ├── ngx_http_browser_module.c
│ │ ├── ngx_http_charset_filter_module.c
│ │ ├── ngx_http_chunked_filter_module.c
│ ├── (省略部分)
│ │ ├── ngx_http_uwsgi_module.c
│ │ ├── ngx_http_xslt_filter_module.c
│ │ └── perl
│ │ ├── Makefile.PL
│ │ ├── nginx.pm
│ │ ├── nginx.xs
│ │ ├── ngx_http_perl_module.c
│ │ ├── ngx_http_perl_module.h
│ │ └── typemap
│ ├── ngx_http.c
│ ├── ngx_http_cache.h
│ ├── ngx_http_config.h
│ ├── ngx_http_header_filter_module.c
│ ├── (省略部分)
│ ├── ngx_http_variables.h
│ └── ngx_http_write_filter_module.c
├── mail
│ ├── ngx_mail_auth_http_module.c
│ ├── ngx_mail.c
│ ├── (省略部分)
│ ├── ngx_mail_ssl_module.c
│ └── ngx_mail_ssl_module.h
├── misc
│ ├── ngx_cpp_test_module.cpp
│ └── ngx_google_perftools_module.c
└── os
└── unix
├── ngx_aio_read.c
├── ngx_aio_read_chain.c
├── ngx_aio_write.c
├── (省略部分)
├── ngx_udp_recv.c
├── ngx_user.c
├── ngx_user.h
└── ngx_writev_chain.c
10 directories, 265 files
编译
1、为了支持rewrite功能,我们需要安装pcre
# yum install pcre* //如过你已经装了,请跳过这一步
2.安装openssl
需要ssl的支持,如果不需要ssl支持,请跳过这一步
# yum install openssl*
3.gzip 类库安装
yum install zlib zlib-devel
(注:如果是Ubuntu的话,直接使用命令sudo apt-get install nginx 进行下载即可)
4、准备好源码,进行解压tar -zxvf nginx-1.8.0.tar.gz
5、编译和安装,执行如下命令:
# cd nginx-1.8.0
# ./configure --prefix=/usr/local/nginx-1.7.0 \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre
–with-http_stub_status_module:支持nginx状态查询
–with-http_ssl_module:支持https
–with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
–with-pcre:为了支持rewrite重写功能,必须制定pcre
(如果这里有提示还需要安装其他的包,安装即可)
设置之后,执行make 结束之后执行 make install
启动命令在/usr/local/nginx-1.8.0/sbin文件下
启动:./nginx
关闭:./nginx -s stop
重启:./nginx -s reload