4

一、安装编译工具及库文件

yum -y install make zlib zlib-devel gcc gcc-c++ libtool  openssl openssl-devel pcre pcre-devel  //PCRE 作用是让 Nginx 支持 Rewrite 功能

二、安装Nginx

1、下载Nginx至文件夹/usr/local内

cd /usr/local/     //进入目标目录
wget http://nginx.org/download/nginx-1.14.1.tar.gz  //下载nginx,选择稳定版本

2、解压缩文件包

tar zxvf nginx-1.14.1.tar.gz

3、进入安装目录,编译安装

./configure --prefix=/app/nginx --with-http_stub_status_module --with-pcre  --with-http_ssl_module

make

make install

安装完成后的摘要信息:

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

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

4、查看Nginx版本

/app/nginx/sbin/nginx -v
 #到此,nginx安装完成。

5、启动、关闭Nginx

检查配置文件是否正确     
/app/nginx/sbin/nginx -t 
/app/nginx/sbin/nginx -V     //可以看到编译选项

启动Nginx

/app/nginx/sbin/nginx     // 启动
/usr/local/nginx/conf/nginx.conf  //配置文件

重新载入配置文件

/app/nginx/sbin/nginx -s reload

重启Nginx,不会改变启动时指定的配置文件

/app/nginx/sbin/nginx -s reopen

停止Nginx

/app/nginx/sbin/nginx -s stop
#或
pkill nginx

boundlessSky
29 声望4 粉丝

[链接]