cent os 6.2 64位 安装ngnix的方法Posted on
从网上整理出来的: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 下载 nginxwget 解压tar –xzvf nginx-1.0.2.tar.gz cd nginx-1.0.2 ./configure 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 模块最后安装make && make install 启服务:可以写成一个脚本:#!/bin/bash/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confexit 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_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using –with-pcre=<path> option.
解决方法是要下载Rewrite模块的正则表达式依赖库:pcre
选择的是:pcre-8.02.tar.gz
地址:?source=dlp
tar -zxvfpcre-8.02.tar.gz
cd pcre-8.02
./configure
make
make install
完成后再执行nginx 下的./configure
一个人负心,或许是因为他的记忆力不好。