ubuntu下nginx的安装

“Nginx (“engine x”) 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。
Nginx 超越 Apache 的高性能和稳定性,使得国内使用 Nginx 作为 Web 服务器的网站也越来越多,其中包括新浪博客、新浪播客、网易新闻等门户网站频道,六间房、56.com等视频分享网站,Discuz!官方论坛、水木社区 等知名论坛,豆瓣、YUPOO相册、海内SNS、迅雷在线等新兴Web 2.0网站。”

安装:

为了确保能在 Nginx 中使用正则表达式进行更灵活的配置,安装之前需要确定系统是否安装有 PCRE(Perl Compatible Regular Expressions)包。您可以到 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包:

# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz
# tar zxvf pcre-8.12.tar.gz
解压后,在配置nginx的时候指定到这个目录即可。

下面开始nginx的安装:

# wget http://sysoev.ru/nginx/nginx-1.0.4.tar.gz
# tar zxvf nginx-1.0.4.tar.gz
# cd nginx-1.0.4
# ./configure --prefix=/usr/local/www/nginx --with-pcre=/yujialin/pcre-8.12 --with-http_stub_status_module --with-http_gzip_static_module
# make
# make install

其中参数 –with-http_stub_status_module 是为了启用 nginx 的 NginxStatus 功能,用来监控 Nginx 的当前状态。至于prefix,就不用我啰嗦了。
注:由于在网上搜到的好多ngnix的源码下载地址打开之后是ERROR 404,上面的那个网址http://sysoev.ru/nginx/nginx-0.8.32.tar.gz是来源于nginx官方的俄文网站,截至2010年1月28日最新的稳定版。

如果你在make 的时候出现“make: *** 没有规则可以创建“default”需要的目标“build”。 停止。”,那么说明你跟我犯了同一个错误,你一定没有注意configure时的错误提示:

./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
–without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
–with-http_ssl_module –with-openssl= options.

看清楚否?没有opensll library!怎么办?装呗!

# sudo apt-get install openssl
# sudo apt-get install libssl-dev

装完之后出现的提示也很有用的,先记下来:

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1 library is not used
+ using system zlib library

nginx path prefix: “/usr/local/nginx”
nginx binary file: “/usr/local/nginx/sbin/nginx”
nginx configuration prefix: “/usr/local/nginx/conf”
nginx configuration file: “/usr/local/nginx/conf/nginx.conf”
nginx pid file: “/usr/local/nginx/logs/nginx.pid”
nginx error log file: “/usr/local/nginx/logs/error.log”
nginx http access log file: “/usr/local/nginx/logs/access.log”
nginx http client request body temporary files: “client_body_temp”
nginx http proxy temporary files: “proxy_temp”
nginx http fastcgi temporary files: “fastcgi_temp”

安装成功后 /usr/local/www/nginx 目录下有四个子目录分别是:conf、html、logs、sbin 。其中 Nginx 的配置文件存放于 conf/nginx.conf,Nginx 只有一个程序文件位于 sbin 目录下的 nginx 文件。确保系统的 80 端口没被其他程序占用,运行 sbin/nginx 命令来启动 Nginx,打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。

posted @ 2011-05-24 20:57  xiao-yu  阅读(17112)  评论(0编辑  收藏  举报