nginx下载地址:http://nginx.org/download/,我选择一个1.6.0版本nginx-1.6.0.tar.gz
建议所有操作要在管理员权限下操作,安装目录在/usr/local下,安装在其他目录可能找不到sbin文件夹。
步骤:
# tar -zxv -f nginx-1.6.0.tar.gz 解压
# cd nginx-1.6.0 到文件目录
# ./configure --prefix=/usr/local/nginx 指定安装路径
# make 编译
# make install 安装
./configure: error: the HTTP rewrite module requires the PCRE library.
解决方法:
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=<path> options.
解决办法:
yum -y install openssl openssl-devel
可能报错3:
解决办法:安装gcc
yum install gcc
再次执行
./configure --prefix=/usr/local/nginx
# make 编译
# make install 安装
nginx编译几个基本的的参数详细列表解释:
--prefix=<path> 指定nginx的安装路径,如果没有指定,默认安装在/usr/local/nginx下。
--sbin-path=<path> nginx的可执行文件的安装路径,这个路径只能够在安装的时候指定,默认为nginx安装路径下的sbin目录下。
--conf-path=<path> 指定nginx的配置文件nginx.conf的路径,默认为<nginx>/conf/nginx.conf。
--pid-path=<path> 指定nginx.pid文件的路径,默认为<nginx>/logs/nginx.conf
--lock-path=<path> 指定nginx.lock路径
--error-log-path=<path> 指定错误日志的路径
--http-log-path=<path> 指定访问日志的路径。
--user=<user> 指定nginx的运行用户,默认为nobody
--group=<group> 指定nginx的运行组,默认为nobody
--with-http_stub_status_module 启用 "server status" 页
--with-openssl=<dir> 指定openssl库源路径
参考备忘: