首先查看nginx编译了什么
cd /usr/local/nginx/sbin/
./nginx -V #查看编译了什么
安装nginx可参考:
一、安装编译时所需依赖库:
yum -y install openssl openssl-devel pcre pcre-devel zlib zlib-devel
二、安装nginx
1.下载nginx安装包
wget http://nginx.org/download/nginx-1.8.0.tar.gz
2.解压nginx-1.8.0.tar.gz
tar -zxvf nginx-1.8.0.tar.gz
3.进入nginx目录
cd nginx-1.8.0
编译nginx配置
./configure –prefix=/usr/local/nginx –user=www –group=www –prefix=/usr/local/nginx –with-http_ssl_module –with-http_stub_status_module
报错总结:
1.出现如下错误,依赖包未安装
nginx重新编译ssl模块详细教程
执行:
yum -y install openssl openssl-devel pcre pcre-devel zlib zlib-devel
出现如下错误,openssl模块未安装或openssl版本问题
nginx重新编译ssl模块详细教程
解决:
(1)执行yum -y install openssl openssl-devel pcre pcre-devel zlib zlib-devel
(2)在进行上述操作(3.4步骤)若还是报错
nginx重新编译ssl模块详细教程
则需源码编译openssl,可参考:http://blog.51cto.com/13363488/2307995
源码编译完成后,再次执行上述3.4步骤
5.编译安装
make(切记不能make install 会覆盖) 把原来nginx备份
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak 把新的nginx覆盖旧的
cp objs/nginx /usr/local/nginx/sbin/nginx
出现错误时cp: cannot create regular file ‘/usr/local/nginx/sbin/nginx’: Text file busy
用cp -rfp objs/nginx /usr/local/nginx/sbin/nginx解决
8.测试nginx是否正确
/usr/local/nginx/sbin/nginx -t
(nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful)
9.重启nginx
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s reload