二、nginx安裝

一、安裝
(1)安裝Nginx及相關組件
(2)Nginx的路徑配置到系統變量中,配完需要重啓系統
因查看網站時,http的ResponseHeaders裏會有服務器信息,例如:Server:nginx,爲了安全,可將服務器信息隱藏掉。1、解壓
1、解壓
tar -zxvf 
unzip nginx-goodies-nginx-sticky-module-ng-08a395c66e42.zip
mv nginx-goodies-nginx-sticky-module-ng-08a395c66e42 nginx-goodies-nginx-sticky-module-ng
2、安裝PCRE
cd pcre-8.38
./configure
make && make install
3、安裝lua模塊
cd openresty-1.13.6.2/bundle/LuaJIT-2.1-20180420/
vim /etc/profile
設置root級環境變量
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
source /etc/profile
增加link連接
ln -s /usr/local/lib/libluajit-5.1.so.2 /lib/libluajit-vi5.1.so.2
4、修改nginx源碼
4.1. src/http/ngx_http_header_filter_module.c
[sw@swfirstbalance nginx-1.14.0]$ vim src/http/ngx_http_header_filter_module.c
找到:
static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;
修改爲:
static u_char ngx_http_server_string[] = "Server: SingleWindow" CRLF;
static u_char ngx_http_server_full_string[] = "Server: SingleWindow" NGINX_VER CRLF;
static u_char ngx_http_server_build_string[] = "Server: SingleWindow" NGINX_VER_BUILD CRLF;
4.2. src/core/nginx.h
[sw@swfirstbalance nginx- 1.14.0]$ vim src/core/nginx.h
找到:
#define NGINX_VERSION " 1.14.0"
#define NGINX_VER "nginx/" NGINX_VERSION
修改爲:
#define NGINX_VERSION "x"
#define NGINX_VER "SingleWindow/" NGINX_VERSION
4.3. src/http/ngx_http_special_response.c
[sw@swfirstbalance nginx-1.14.0]$ vim src/http/ngx_http_special_response.c
找到:
static u_char ngx_http_error_tail[] =
"<hr><center>nginx</center>" CRLF
"</body>" CRLF
"</html>" CRLF
修改爲:
static u_char ngx_http_error_tail[] =
"<hr><center>SingleWindow</center>" CRLF
"</body>" CRLF
"</html>" CRLF
5、安裝nginx
./configure --prefix=/soft/nginx/nginx-1.14.0 \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_realip_module \
--with-pcre=../nginx-other-module/pcre-8.38 \
--with-openssl=../nginx-other-module/openssl-1.0.2p \
--with-zlib=../nginx-other-module/zlib-1.2.11 \
--add-module=../nginx-other-module/nginx-goodies-nginx-sticky-module-ng \
--add-module=../nginx-other-module/nginx_upstream_check_module-0.3.0 \
--add-module=../nginx-other-module/lua-nginx-module-0.10.13 \
make
make install
二、nginx常用命令
1、在sbin目錄下
nginx安裝路徑
nginx啓動路徑nginx/sbin
  (1) nginx 啓動nginx
  (2)nginx -v 查看nginx版本
  (3)nginx -s reload 重新載入配置文件
  (4)nginx -s reopen 重啓 Nginx
  (5)nginx -s stop 停止nginx
  (6)nginx安裝完成後目錄結構
三、常用的第三方模塊
1、OpenSSL是一種功能強大的商用級全功能工具包,適用於傳輸層安全性(TLS)和安全套接字層(SSL)協議。它也是一個通用的加密庫。
2、zlib:
一個大型漂亮但又精美不引人注目的壓縮庫(也是免費的,不提及不受專利限制)
3、lua模塊
ngx_lua將Lua嵌入Nginx,可以讓Nginx執行Lua腳本,並且高併發、非阻塞的處理各種請求。Lua內建協程,這樣就可以很好的將異步回調轉換成順序調用的形式。
4、nginx_upstream_check_module
nginx_upstream_check_module-master 這個就是淘寶技術團隊開發的 Nginx 模塊 ,通過它可以用來檢測後端 realserver 的健康狀態。如果後端 realserver 不可用,則所有的請求就不會轉發到該節點上。
5、
PCRE(Perl Compatible Regular Expressions)是一個Perl庫,包括 perl 兼容的正則表達式庫。
四、nginx內部模塊
nginx模塊分爲以下幾類:
NGX_CORE_MODULE  //核心模塊
NGX_HTTP_MODULE  //HTTP處理模塊
NGX_EVENT_MODULE //事件處理模塊
NGX_MAIL_MODULE  //郵件處理模塊
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章