我的环境:CenterOS 6.7 Ngnix1.10.2
1.解决依赖的问题
// 执行命令之前,记得先将DNS设置为114.114.114.114/8.8.8.8,不然各种下载失败.
// 如果你网络不通畅,可能会得到提示说你的pcre是最新的,我就出现过
yum install -y pcre pcre-devel
yum install -y openssl openssl-devel
//安装成功的最终提示符"Complete!"
我发现有博文说 gcc,openssl,zlib,pcre有这么多依赖,而且可以通过rpm -q来检测.但是到我这出问题了.我检测出来全部有,就是安装的时候不成功,卡在make那一步,估计是依赖的版本不支持nginx,如果你安装的也是新版的,建议先执行上面两行命名
2.下载nginx
wget http://nginx.org/download/nginx-1.10.2.tar.gz
3.解压 ,切换到解压缩后的目录
tar -zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
3.设置配置信息
// 下面这一句直接复制就可以
// 注意/home/nginx-1.10.2这个是你解压缩的目录,不然就是各种失败了
./configure --prefix=/home/nginx-1.10.2 --conf-path=/home/nginx-1.10.2/nginx.conf --with-http_stub_status_module --with-http_ssl_module
// 完毕!
//我在执行这个命令时会输出很多东西,需要的可以参考一下,(至少我在失败时,很快就执行完毕了,而且结果也不对)
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/home/nginx-1.10.2"
nginx binary file: "/home/nginx-1.10.2/sbin/nginx"
nginx modules path: "/home/nginx-1.10.2/modules"
nginx configuration prefix: "/home/nginx-1.10.2"
nginx configuration file: "/home/nginx-1.10.2/nginx.conf"
nginx pid file: "/home/nginx-1.10.2/logs/nginx.pid"
nginx error log file: "/home/nginx-1.10.2/logs/error.log"
nginx http access log file: "/home/nginx-1.10.2/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
4.make && make install
如果前面配置出错,或者依赖出错的话,那么这一步就会痛不欲生.
5.验证nginx
/home/nginx-1.10.2/sbin/nginx -v
//如果成功会得到结果
nginx version: nginx/1.10.2
写的不详细,还请见谅
参考:
http://www.linuxidc.com/Linux/2016-07/133463.htm
http://blog.youkuaiyun.com/forever_forest/article/details/8994360
本文出处:https://my.oschina.net/longfong/blog/803368