cent os 6.2 64位 安装ngnix的方法

从网上整理出来的:cent os6.2 64位 安装ngnix的方法。

环境准备工作:
 yum -y install gcc gcc-c++ autoconf automake make  
 yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel   

下载 nginx
 wget http://nginx.org/download/nginx-1.0.2.tar.gz  


解压
 tar –xzvf nginx-1.0.2.tar.gz  
 cd nginx-1.0.2  
 ./configure  

configure 支持下面的选项:

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

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

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

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

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

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

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

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

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

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

--with-rtsig_module - 启用 rtsig 模块


最后安装
 make && make install  

启服务:
可以写成一个脚本:
#!/bin/bash
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
exit 0

检测进程是否已启:
ps -ef | grep nginx
检测端口是否占用
netstat  -anp | grep 8080 查看指定的端口

在浏览器中输入IP:PORT
Welcome to nginx!

有可能出现的问题: 防火墙是否关闭  iptables 和 selinux

了解Nginx,可以看看张宴的《实战Nginx:取代Apache的高性能Web服务器》这本书,主要是教人怎么用Nginx.

**************************************** 

在red hat 6.2 64bit安装时会出现如下错误:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.

解决方法是要下载Rewrite模块的正则表达式依赖库:pcre

选择的是: pcre-8.02.tar.gz

地址:http://sourceforge.net/projects/pcre/?source=dlp

tar -zxvf  pcre-8.02.tar.gz

cd pcre-8.02

./configure

make

make install 

完成后再执行nginx 下的./configure

转载于:https://www.cnblogs.com/fangshenghui/archive/2013/05/12/3074580.html

你可能感兴趣的:(cent os 6.2 64位 安装ngnix的方法)