原文鏈接: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中