日期:2014-05-16  浏览次数:20681 次

linux 安装Nginx-0.8.54
今天安装了nginx,主要参考下面的两篇文章。主要是第一篇,但需要注意的是–prefix=/usr/webserver/nginx/ 后面加“/” 指示一个目录,否则会提示你参数无效。

在某些环境下没有安装编译环境时 ,在安装pcre的时候 会出现libtool: compile: unrecognized option `-DHAVE_CONFIG_H' 的错误,我安装libtool  gcc-c++ 解决问题



yum install  libtool 

yum install -y gcc-c++



yum install zlib zlib-devel





为了确保能在 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
# cd pcre-8.12
# ./configure
# make
# make install



接下来安装 Nginx,Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /opt/nginx 目录下的详细步骤:

# wget http://nginx.org/download/nginx-0.8.54.tar.gz
# tar zxvf nginx-0.8.54.tar.gz
# cd nginx-0.8.54
# ./configure --with-http_stub_status_module –prefix=/usr/webserver/nginx --with-pcre=/usr/src/pcre-8.12
# make
# make install

其中参数 --with-http_stub_status_module 是为了启用 nginx 的 NginxStatus 功能,用来监控 Nginx 的当前状态。

with-pcre=/usr/src/pcre-8.12 指的是pcre-8.12 的源码路径,并不是安装路径。



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

以上摘自 http://hi.baidu.com/zhrt/blog/item/993a30c7899339c8d00060dc.html


安装nginx (2008-11-25 17:42)
分类: linux

今天装完红帽5的时候发现忘记装apache了,但是回头想想apache装了很多了,最近nginx很火,据说可以支持5w的并发,于是自己装一个看看。

首先到这个网站可以下载源码包:

http://www.nginx.cn/

我是下在root目录下的,输入:

[root@localhost software]# tar -zxvf nginx-0.6.33

然后进入目录输入:

[root@localhost software]# cd nginx-0.6.33

接着开始编译源代码:

[root@localhost nginx-0.6.33]#./configure\

--prefix=/usr/local/nginx/\

--sbin-path=/usr/local/nginx/nginx\

--conf-path=/usr/local/nginx/nginx.conf\

--error-log-path=/usr/local/nginx/nginx.error\

--with-http_perl_module \

--without-http_rewrite_moduleOption

由于我的电脑中没有安装PCRE库,所以只有把增加    --without-http_rewrite_moduleoption 才能通过编译。

以下是./configure的选项

--prefix=<path> - Nginx安装路径。如果没有指定,默认为 /usr/local/nginx。

--sbin-path=<path> - Nginx可执行文件安装路径。只能安装时指定,如果没有指定,默认为<prefix>/sbin/nginx。

--conf-path=<path> - 在没有给定-c选项下默认的nginx.conf的路径。如果没有指定,默认为<prefix>/conf/nginx.conf。

--pid-path=<path> - 在nginx.conf中没有指定pid指令的情况下,默认的nginx.pid的路径。如果没有指定,默认为 <prefix>/logs/nginx.pid。

--lock-path=<path> - nginx.lock文件的路径。

--error-log-path=<path> - 在nginx.conf中没有指定error_log指令的情况下,默认的错误日志的路径。如果没有指定,默认为 <prefix>/logs/error.log。

--http-log-path=<path> - 在nginx.conf中没有指定access_log指令的情况下,默认的访问日志的路径。如果没有指定,默认为 <prefix>/logs/access.log。

--user=<user> - 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的用户。如果没有指定,默认为 nobody。

--group=<group> - 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的组。如果没有指定,默认为 nobody。

--builddir=DIR - 指定编译的目录

--with-rtsig_module - 启用 rtsig 模块

--with-select_module --without-select_module - Whether or not to enable the select module. This module is enabled by default if a more suitable method such as kqueue, epoll, rtsig or /dev/poll is not discovered by configure.

//允许或不允许开启SELECT模式,如果 configure 没有找到更合适的模式,比如:kqueue(sun os),epoll (linux kenel 2.6+), rtsig(实时信号)或者/dev/poll(一种类似select的模式,底层实现与SELECT基本相 同,都是采用轮训方法) SELECT模式将是默认安装模式

--with-poll_module --witho