Nginx编译参数和进程管理介绍(二)
本文介绍两个部分:Nginx的编译参数以及nginx的进程管理。文章总体层次架构如图所示:
<a href="https://s4.51cto.com/wyfs02/M00/9C/D4/wKiom1l2w4HzfesVAABadoHnZy0942.png" target="_blank"></a>
一、Nginx编译参数详解
从源代码编译应用程序时通常有三个步骤:配置,编译和安装,十分简单。其中配置步骤十分的重要,这直接决定了你的应用程序具备什么功能。所有编译安装时一定要特别重视配置的选项参数。
Nginx的配置选项有如下:
1.Path选项
指定编译安装的各种路径位置。
<a href="https://s1.51cto.com/wyfs02/M01/9C/D4/wKioL1l2xKnihpzKAADAF-URE8g650.png" target="_blank"></a>
2.依赖选项
指定需要依赖的库文件。
<a href="https://s1.51cto.com/wyfs02/M00/9C/D4/wKioL1l2xQqxk8TxAADDQDpGyoM999.png" target="_blank"></a>
<a href="https://s4.51cto.com/wyfs02/M01/9C/D4/wKiom1l2xQvhZfvWAABq4zegLns119.png" target="_blank"></a>
3.模块选项
指明需要安装模块,安装的模块决定了你需要额外附加哪些功能。
3.1、默认启用的模块
<code>以下参数允许您禁用默认情况下启用的模块:</code>
<code>–without-http_charset_module</code>
<code>–without-http_gzip_module</code>
<code>–without-http_ssi_module</code>
<code>–without-http_userid_module</code>
<code>–without-http_access_module</code>
<code>–without-http_autoindex_module</code>
<code>–without-http_geo_module</code>
<code>–without-http_map_module</code>
<code>–without-http_referer_module</code>
<code>–without-http_rewrite_module</code>
<code>–without-http_proxy_module</code>
<code>–without-http_fastcgi_module</code>
<code>–without-http_uwsgi_module</code>
<code>–without-http_scgi_module</code>
<code>–without-http_memcached_module</code>
<code>–without-http_limit_conn_module</code>
<code>–without-http_limit_req_module</code>
<code>–without-http_empty_gif_module</code>
<code>–without-http_browser_module</code>
<code>–without-http_upstream_ip_hash_module</code>
<code>–without-http_upstream_least_conn_module</code>
<code>–without-http_split_clients_module</code>
3.2、默认禁用的模块
<code>以下参数允许您启用默认禁用的模块:</code>
<code>–with-http_ssl_module</code>
<code>–with-http_realip_module</code>
<code>–with-http_addition_module</code>
<code>–with-http_xslt_module</code>
<code>–with-http_image_filter_module</code>
<code>–with-http_geoip_module</code>
<code>–with-http_sub_module</code>
<code>–with-http_dav_module</code>
<code>–with-http_flv_module</code>
<code>–with-http_mp4_module</code>
<code>–with-http_gzip_static_module</code>
<code>–with-http_random_index_module</code>
<code>–with-http_secure_link_module</code>
<code>–with-http_stub_status_module</code>
<code>–with-google_perftools_module</code>
<code>–with-http_degradation_module</code>
<code>–with-http_perl_module</code>
<code>–with-http_spdy_module</code>
<code>–with-http_gunzip_module</code>
<code>–with-http_auth_request_module</code>
3.3、常用编译配置选项参考
<code>.</code><code>/configure</code> <code>--prefix=</code><code>/usr/local/nginx</code> <code>--conf-path=</code><code>/etc/nginx/nginx</code><code>.conf --error-log-path=</code><code>/var/log/nginx/error</code><code>.log --http-log-path=</code><code>/var/log/nginx/access</code><code>.log --pid-path=</code><code>/var/run/nginx</code><code>.pid --lock-path=</code><code>/var/run/nginx</code><code>.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_stub_status_module --with-threads --with-</code><code>file</code><code>-aio</code>
二、Nginx的进程管理
1.Nginx命令行选项
Nginx命令行选项可以用如下命令查看
<code>[root@nginx nginx-1.12.0]</code><code># nginx -h</code>
<code>nginx version: nginx</code><code>/1</code><code>.12.0</code>
<code>Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]</code>
<code>Options:</code>
<code> </code><code>-?,-h : this help</code>
<code> </code><code>-</code><code>v</code> <code>: show version and </code><code>exit</code>
<code> </code><code>-V : show version and configure options </code><code>then</code> <code>exit</code>
<code> </code><code>-t : </code><code>test</code> <code>configuration and </code><code>exit</code>
<code> </code><code>-T : </code><code>test</code> <code>configuration, dump it and </code><code>exit</code>
<code> </code><code>-q : suppress non-error messages during configuration testing</code>
<code> </code><code>-s signal : send signal to a master process: stop, quit, reopen, reload</code>
<code> </code><code>-p prefix : </code><code>set</code> <code>prefix path (default: </code><code>/usr/local/nginx/</code><code>)</code>
<code> </code><code>-c filename : </code><code>set</code> <code>configuration </code><code>file</code> <code>(default: </code><code>/etc/nginx/nginx</code><code>.conf)</code>
<code> </code><code>-g directives : </code><code>set</code> <code>global directives out of configuration </code><code>file</code>
2.启动和停止Nginx进程
直接输入nginx既可以启动nginx,另外可以通过nginx -s signal发送信号来指定nginx进程的操作。
<code>nginx </code><code>#启动nginx</code>
<code>nginx -s stop </code><code>#立即停止守护进程(使用TERM信号)</code>
<code>nginx -s quit </code><code>#正常停止守护程序(使用QUIT信号)</code>
<code>nginx –s reopen </code><code>#重新打开日志文件</code>
<code>nginx –s reload </code><code>#重新加载配置</code>
<code>nginx -p prefix </code><code>#指定安装路径</code>
<code>nginx -c filename </code><code>#指明配置文件路径</code>
<code>killall nginx </code><code>#杀死nginx进程</code>
<code></code>
本文转自 PowerMichael 51CTO博客,原文链接:http://blog.51cto.com/huwho/1950733,如需转载请自行联系原作者