读书人

linux上nginx安装

发布时间: 2013-02-19 11:11:40 作者: rapoo

linux下nginx安装

nginx安装

可以用root安装,也可以用其他用户sudo安装,还是用root安装简单

需要先装gcc,我的已经安了,

[oracle@dev Server]$ rpm -q gcc
gcc-4.1.2-51.el5

?

prce也安了,不是最新的

[oracle@dev sbin]$ rpm -q pcre
pcre-6.6-6.el5_6.1

?

安装pcre (让nginx支持rewrite)

下载最新PCRE(Perl Compatible Regular Expressions)源码包

http://www.pcre.org/

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz

?

使用下面命令下载编译和安装 PCRE 包:
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz?下载
# tar zxvf pcre-8.21.tar.gz
# cd pcre-8.21

# ./configure
# make
# sudo make install

?

安装nginx

下载地址

http://nginx.org/en/download.html

[oracle@dev opt]tar zxvf nginx-1.3.12.tar.gz

[oracle@dev opt] cd nginx-1.3.12

[oracle@dev nginx-1.3.12]$ ./configure --with-http_stub_status_module

[oracle@dev nginx-1.3.12]$ make install
[oracle@dev nginx-1.3.12]$ sudo make install

?

启动nginx

oracle@dev nginx-1.3.12]$ cd /usr/local/nginx/sbin
[oracle@dev sbin]$ sudo ./nginx &
[2] 16121

要是出现如下信息说明端口被占用了,我的是被weblogic占用了,可先停止webloigc,或修改weblogic端口
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

?

访问地址

http://localhost/
linux上nginx安装

?

停止nginx

[oracle@dev sbin]$ sudo ./nginx -s stop

[oracle@dev sbin]$ sudo ./nginx -s quit

?

Nginx -s stop???????? 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。(quick exit)
Nginx -s quit???????? 平稳关闭Nginx,保存相关信息,有安排的结束web服务。(graceful exit)
Nginx -s reload?????? 因改变了Nginx相关配置,需要重新加载配置而重载。(changing configuration,start a new worker,quitting an old worker gracefully.)
Nginx -s reopen?????? 重新打开日志文件。(reopenging log files)

?

以下是./configure的选项

--with-pcre=DIR - 指定 PCRE 库的源代码的路径。

--with-pcre-opt=OPTIONS - Set additional options for PCRE building.

--with-md5=DIR - Set path to md5 library sources.

--with-md5-opt=OPTIONS - Set additional options for md5 building.

--with-md5-asm - Use md5 assembler sources.

--with-sha1=DIR - Set path to sha1 library sources.

--with-sha1-opt=OPTIONS - Set additional options for sha1 building.

--with-sha1-asm - Use sha1 assembler sources.

--with-zlib=DIR - Set path to zlib library sources.

--with-zlib-opt=OPTIONS - Set additional options for zlib building.

--with-zlib-asm=CPU - Use zlib assembler sources optimized for specified CPU, valid values are: pentium, pentiumpro

--with-openssl=DIR - Set path to OpenSSL library sources

--with-openssl-opt=OPTIONS - Set additional options for OpenSSL building

--with-debug - 启用调试日志

--add-module=PATH - Add in a third-party module found in directory PATH

?

参考了:

http://www.cnblogs.com/xd502djj/archive/2011/11/23/2260239.html

http://wiki.nginx.org/ChsInstall

http://wwwzhouhui.iteye.com/blog/1305512

http://www.2cto.com/os/201206/136381.html

http://www.myhack58.com/Article/48/66/2010/28645.htm

?

?

读书人网 >UNIXLINUX

热点推荐