原文链接:http://www.cnblogs.com/Detector/p/6946388.html
安装
获取安装包
使用如下的命令可以在nginx官网获取安装包,博主获取的是nginx-1.11.5这个版本
wget http://nginx.org/download/nginx-1.11.5.tar.gz
解压安装包
tar -zxvf nginx-1.11.5.tar.gz
切换到 nginx-1.11.5 目录
执行 nginx下的configure进行配置
./configure
错误一
checking for C compiler ... not found
./configure: error: C compiler cc is not found
原因定位:没有安装gcc
解决方法:使用root用户 执行 yum install gcc
gcc安装成功界面:
再次执行 ./configure
错误二
./configure: error: the HTTP rewrite module requires the PCRE library.
原因: 缺少pcre包
解决方法:yum -y install pcre-devel 进行安装
安装后再次执行./configure
错误三
错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library
原因:需要进行md5加密操作的没有找到md5模块
解决方法:yum -y install openssl openssl-devel 安装openssl加密模块
再次执行./configure,终于成功了
然后再执行 make &&make install,执行过程没有报错,终于安装成功了
启动
nginx的启动目录在 /usr/local/nginx/sbin 下
直接进入该安装目录下,输入命令 ./nginx -t 即可启动
执行 ./nginx -s reload 可以进行重启操作
修改配置文件
nginx的配置在/usr/local/nginx 目录下的conf中