使用wget命令 下载nginx 1.9.5 源码 下载到/usr/nginx 目录下
wget -nd -p --directory-prefix=/usr/nginx http://nginx.org/download/nginx-1.9.5.tar.gz
解压源码 到/usr/nginx 目录
tar -zxvf /usr/nginx/nginx-1.9.5.tar.gz -C /usr/nginx
编译源码
cd /usr/nginx/nginx-1.9.5
输入 ./configure --prefix=/usr/nginx/nginx 安装到/usr/nginx/nginx 目录
可能报一下错误
./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=<path> option.
http模块 rewrite 缺少PCRE 依赖库
出现以下错误
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option
gzip 压缩模块 缺少 zlib 依赖库
清除 编译安装过程中临时文件
make clean 清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件。
make distclean 类似make clean,但同时也将configure生成的文件全部删除掉,包括Makefile文件
4.进入 sbin 目录 启动nginx
./nginx
注意:服务器防火墙必须放开 80端口