nginx是一款高效能的HTTP和反向 Proxy伺服器,可以做到httpmail等的反向 Proxy加速。其採用線程響應使用者請求。
優點是佔用記憶體空間少,但卻不太穩定,使用epoll機制,最大並發串連請求能夠達到50000個
nginx的搭建:
1.先安裝pcre和livevent{源碼安裝}libevent的官網libevent.org最新版本是2.0.18650) this.width=650;" style="border-bottom:#ddd 1px solid;border-left:#ddd 1px solid;border-top:#ddd 1px solid;border-right:#ddd 1px solid;" src="/e/u/themes/default/images/spacer.gif" alt="spacer.gif" />上傳所需要的軟體包650) this.width=650;" title="2013-09-20_125157.png" src="http://img1.51cto.com/attachment/201309/125546544.png" alt="125546544.png" />安裝libevent拆解tar-zxvflibevent-2.0.16-stable.tar.gz-C/usr/local/src/[root@localhostnginx]#cd/usr/local/src/libevent-2.0.16-stable/[root@localhostlibevent-2.0.16-stable]#./configure--prefix=/usr/local/libevent指明安裝路徑make&&makeinstall編譯安裝650) this.width=650;" title="2013-09-20_125406.png" src="http://img1.51cto.com/attachment/201309/125701530.png" alt="125701530.png" />處理庫檔案[root@localhostlibevent]#vim/etc/ld.so.conf.d/libevent.conf指明庫檔案位置編輯文檔裡面填上/usr/local/libevent/lib即可650) this.width=650;" title="2013-09-20_125513.png" src="http://www.bkjia.com/uploads/allimg/131228/1450534Z2-2.png" width="638" height="175" alt="125806578.png" />處理標頭檔[root@localhostlibevent]#ln-s/usr/local/libevent/include//usr/include/libevent做符號連結即可2.安裝pcre650) this.width=650;" title="2013-09-20_125626.png" src="http://www.bkjia.com/uploads/allimg/131228/1450531Z5-3.png" width="647" height="81" alt="125920353.png" />兩者安裝上即可[root@localhostServer]#rpm-ivhpcre-devel-6.6-2.el5_1.7.i386.rpm3.安裝nginxgroupadd-rnginx建組useradd-r-gnginx-s/bin/nologin-Mnginx使用者[root@localhostnginx]#tar-zxvfnginx-1.0.11.tar.gz-C/usr/local/src/拆解[root@localhostnginx-1.0.11]./configure\沒有指明安裝位置prefix)預設在/usr/local/nginx目錄下)--conf-path=/etc/nginx/nginx.conf\設定檔的位置--error-log-path=/var/log/nginx/error.log\--http-log-path=/var/log/nginx/access.log\--pid-path=/var/run/nginx/nginx.pid\--lock-path=/var/lock/nginx.lock\--user=nginx\--group=nginx\--with-http_ssl_module\--with-http_flv_module\--with-http_stub_status_module\--with-http_gzip_static_module\--http-client-body-temp-path=/var/tmp/nginx/client/\--http-proxy-temp-path=/var/tmp/nginx/proxy/\--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/\--with-pcremake&&makeinstall編譯安裝4.網頁的應用基於ip地址訪問網頁編輯nginx的設定檔/etc/nginx/nginx.conf
650) this.width=650;" style="float:none;" title="2013-09-20_125832.png" src="http://img1.51cto.com/attachment/201309/130154377.png" width="656" height="261" alt="130154377.png" />
基於主機頭訪問網頁,需要DNS解析修改hosts檔案即可)
650) this.width=650;" style="float:none;" title="2013-09-20_125840.png" src="http://img1.51cto.com/attachment/201309/130157560.png" alt="130157560.png" />
測試
650) this.width=650;" style="float:none;" title="2013-09-20_125848.png" src="http://img1.51cto.com/attachment/201309/130200687.png" width="661" height="151" alt="130200687.png" />
本文出自 “那些曾經” 部落格,請務必保留此出處http://slayr.blog.51cto.com/7613374/1299132