|
|
Nginx [engine x]是Igor Sysoev编写的一个HTTP和反向代理服务器,另外它也可以作为邮件代理服务器。 它已经在众多流量很大的俄罗斯网站上使用了很长时间,这些网站包括Yandex、Mail.Ru、VKontakte,以及Rambler。
据Netcraft统计,在2012年8月份,世界上最繁忙的网站中有11.48%使用Nginx作为其服务器或者代理服务器。目前互联网主流公司360、百度、新浪、腾讯、阿里等都在使用nginx作为自己的WEB服务器。
Nginx由内核和模块组成,其中,内核的设计非常微小和简洁,完成的工作也非常简单,仅仅通过查找配置文件将客户端请求映射到一个location block(location是Nginx配置中的一个指令,用于URL匹配),而在这个location中所配置的每个指令将会启动不同的模块去完成相应的工作。
Nginx相对于Nginx优点:
高并发响应性能非常好,官方Nginx处理静态文件并发5w/s
反向代理性能非常好。(可用于负载均衡)
内存和cpu占用率低。(为Nginx的1/5-1/10)
功能较Nginx少(常用功能均有)
对php可使用cgi方式和fastcgi方式。
Nginx WEB安装
首先需要安装pcre库,然后再安装Nginx:
#安装pcre支持rewrite库,也可以安装源码,注*安装源码时,指定pcre路径为解压
源码的路径,而不是编译后的路径,否则会报错
(make[1]: *** [/usr/local/pcre/Makefile] Error 127 错误)
yum install pcre-devel pcre -y
#下载Nginx源码包
cd /usr/src ;wget -c http://nginx.org/download/nginx-1.4.2.tar.gz
#解压Nginx源码包
tar -xzf nginx-1.4.2.tar.gz
#进入解压目录,然后sed修改Nginx版本信息为WS
cd nginx-1.4.2 ; sed -i -e 's/1.4.2//g' -e 's/nginx\//WS/g' -e
's/"NGINX"/"WS"/g' src/core/nginx.h
#预编译Nginx
useradd www ;./configure --user=www --group=www --prefix=/usr/local/nginx --with-
http_stub_status_module --with-http_ssl_module
#.configure预编译成功后,执行make命令进行编译
make
#make执行成功后,执行make install 正式安装
make install
#自此Nginx安装完毕
/usr/local/nginx/sbin/nginx -t 检查nginx配置文件是否正确,返回OK即正确。
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
然后启动nginx,/usr/local/nginx/sbin/nginx 回车即可。查看进程是否已启动:
ps -ef |grep nginx
nobody 5381 30285 0 May16 ? 00:04:31 nginx: worker process
root 30285 1 0 2026 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
root 32260 32220 0 12:34 pts/0 00:00:00 grep nginx
然后我们可以通过docker 的ip去访问即可。 |
|