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,如需轉載請自行聯系原作者