【概述】
nginx是種跟apache類似的web服務器。但其做爲新興事物,所以借鑑和融合了很多新技術。最爲常用的除了web服務器,就是做爲負載均衡使用的反向代理和緩存服務器。所以根據其功能和需求,大致的網絡架構也分爲LNMP、LNNMP和LNNNMP。
LNMP是和LAMP同樣的平臺結構。是由L(Linux)+N(nginx)+M(mysql)+P(php)組成。這時的Nginx是做web服務器使用。
LNNMP是在LNMP上做的擴展。它利用了Nginx負載均衡的反向代理功能,是LNMP平臺多了負載均衡功能。
LNNNMP更是在LNNMP上的擴展。它除了擁有LNMP的平臺功能和LNNMP的負載均衡功能,還額外添加了緩存服務器的功能。
【結構圖】
【nginx的編譯安裝】
#yum -y install gcc openssl-devel pcre-devel zlib-devel//安裝編譯環境
#tar xf nginx-1.4.7.tar.gz //解壓源碼包
#cd nginx-1.4.7
#./configure \//檢查編譯環境
--prefix=/usr \
--sbin-path=/usr/sbin/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/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
#make && make install//編譯安裝
#/usr/sbin/nginx -t//檢查語法錯誤
#useradd -r nginx//添加用戶
#mkdir /var/tmp/nginx//創建目錄
#/usr/sbin/nginx//啓動nginx
#killall nginx//關閉手動打開的nginx進程
#vim /etc/rc.d/init.d/nginx//創建nginx啓動文件
#chmod +x /etc/rc.d/init.d/nginx//賦予文件可執行權限
#chkconfig --add nginx//把nginx添加入服務
#service nginx start//開啓nginx服務
#chkconfig nginx on//設置爲開機啓動