安装依赖

  1. yum install pcre pcre-devel -y
  2. yum install openssl openssl-devel -y
  3. yum install zlib zlib-devel -y

解压安装包

  1. tar -zxvf nginx-1.12.2.tar.gz

安装

  1. ./configure && make && make install
  1. ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

启动

  1. cd /usr/local/nginx/sbin
  2. ./nginx

设置软链接

  1. ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

nginx命令

  1. nginx -s reload
  2. nginx -s stop
  3. # 测试nginx.conf配置
  4. nginx -t -c /usr/local/nginx/conf/nginx.conf

错误

1001错误

当使用 root 用户进行解压操作后,用户及用户组显示为 1001

使用命令 chown -R root:root nginx 来改变目录拥有者