1. 安装准备 依赖库安装 (PCRE库、zlib库、ssl)

  1. > cd /sour cecode/soft
  2. # 安装PCRE库
  3. > tar -zxvf pcre-8.38.tar.gz
  4. > cd pcre-8.38
  5. > ./configure
  6. > make
  7. > make install
  8. # 安装zlib库
  9. > cd /sourcecode/soft
  10. > tar -zxvf zlib-1.2.11.tar.gz
  11. > cd zlib-1.2.11
  12. > ./configure
  13. > make
  14. > make install
  15. # 安装ssl
  16. > cd /sourcecode/soft
  17. > tar -zxvf openssl-1.0.1t.tar.gz


2. 安装nginx

nginx文件放在 /usr/local/src 文件夹下

> cd /usr/local/src
> tar -zxvf nginx-1.14.0.tar.gz
> cd nginx-1.14.0
# 运行以下指令
./configure --sbin-path=/usr/local/nginx/nginx \
        --conf-path=/usr/local/nginx/nginx.conf \
        --pid-path=/usr/local/nginx/nginx.pid \
        --with-http_ssl_module \
        --with-pcre=/sourcecode/soft/pcre-8.38 \
        --with-zlib=/sourcecode/soft/zlib-1.2.11 \
        --with-openssl=/sourcecode/soft/openssl-1.0.1t
# 安装
> make&&make install


3. 启动nginx

> cd /usr/local/nginx
# 启动
> ./nginx -c nginx.conf
# 重新启动
> ./nginx -s reload

/usr/local/nginx/nginx -c ./nginx.conf

如果系统中还有其他nginx,这么启动可能会碰到启动其他nginx,需要指定目录启动

# 指定目录启动
> /usr/local/nginx/nginx -c ./nginx.conf