Linux 下安装nginx1.12
原创    xingfu2017    发表于:2017-04-19 17:50:14
  阅读 :250   收藏   编辑

安装系统:Centos6 64位
nginx版本:1.12

  • 下载nginx1.12

wget http://nginx.org/download/nginx-1.12.0.tar.gz
  • 使可执行

chmod  +x nginx-1.12.0.tar.gz
  • 解压

tar -zxvf nginx-1.12.0.tar.gz
  • 重命名

mv nginx-1.12.0 nginx1.12
  • configure

    configure命令是用来检测平台环境,依赖等。

cd nginx1.12
./configure
  • 可能出现的错误

./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.
缺少pcre,zlib依赖 前者为了重写rewrite,后者为了gzip压缩 


安装依赖包:pcre
yum -y install pcre-devel

安装依赖包 zlib
yum -y install zlib-devel

./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library...
缺少openssl依赖

安装依赖包openssl-devel
yum -y install openssl openssl-devel
  • 再次configure

./configure
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"     
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/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"

默认安装nginx路径为 “/usr/local/nginx”;
编译时可以指定安装路径 —prefix= your path

  • 编译

make
  • 安装

make install
  • 相关命令

启动  /usr/local/nginx/sbin/nginx
停止/重新加载 /usr/local/nginx/sbin/nginx -s stop(reload)
验证配置文件是否合法 /usr/local/nginx/sbin/nginx -t

评论
条评论

推荐阅读