linux系统为Centos 64位
第一步:从http://nginx.org/download/上下载相应的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下载)
第二步:解压 tar -zxvf nginx-1.5.9.tar.gz
第三步:设置一下配置信息 ./configure –prefix=/usr/local/nginx ,或者不执行此步,直接默认配置
第四步:
make 编译 (make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件)
make install 安装 (make install是把这些编译出来的可执行文件和库文件复制到合适的地方)
启动方式:
nginx默认安装到/usr/local目录下面
/usr/local/nginx/sbin/nginx
如果在第三步执行了./configure –prefix=/usr/local/nginx,则执行
/usr/nginx/sbin/nginx
常见错误及解决办法:
1、./configure: error: the HTTP rewrite module requires the PCRE library.
解决方案:安装pcre-devel解决问题
yum -y install pcre-devel
2、./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.
解决方案:
yum -y install openssl openssl-devel
3、如果安装出现在下面的错误是缺少编译环境。安装编译源码所需的工具和库 ./configure: error: C compiler cc is not found
yum install gcc gcc-c++ ncurses-devel perl
4、安装cmake,从http://www.cmake.org下载源码并编译安装
yum -y install make gcc gcc-c++ ncurses-devel
yum -y install zlib zlib-devel
5、如果需要ssl功能需要openssl库
yum -y install openssl openssl--devel