针对centos 7.2 64位
1、建立用户组
groupadd -r nginx //-r表示创建系统工作组,且工作组的ID小于500
useradd -r -g nginx -M nginx //-r表示创建系统用户 -g表示属于nginx组 -M表示不自动生成登录目录
2、下载nginx安装包
wget -c http://nginx.org/download/nginx-1.10.3.tar.gz //到官网找到最新的安装包地址
3、解压nginx安装包
tar -zxvf nginx-1.10.3.tar.gz -C /usr/local/src //-C解压到指定目录
cd /usr/local/src
4、安装必要的依赖包
yum -y install pcre-devel
yum -y install gcc gcc-c++ ncurses-devel perl
yum -y install openssl openssl-devel
5、安装nginx
./configure \
--conf-path=/etc/nginx/nginx.conf \ //设置nginx.conf配置文件路径
--error-log-path=/var/log/nginx/error.log \ //设置错误日志error.log路径
--http-log-path=/var/log/nginx/access.log \ //设置http日志access.log路径
--pid-path=/var/run/nginx/nginx.pid \ //设置nginx的PID文件路径
--lock-path=/var/lock/nginx.lock \ //设置nginx的锁文件路径
--user=nginx \ //设置工作进程的用户
--group=nginx \ //设置工作进程的群组
--with-http_ssl_module \ //ssl模块,需要openssl依赖包支持
--with-http_flv_module \ //flash模块
--with-http_stub_status_module \ //用来监控 Nginx 的当前状态
--with-http_gzip_static_module \ //支持压缩
--http-client-body-temp-path=/var/tmp/nginx/client/ \ //字面意思,设置客户端文件的临时目录
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \ //设置反向代理临时目录
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ //设置公共网关接口临时目录
--with-pcre //pcre模块
make && make install
mkdir -p /var/tmp/nginx/client //-p生成client目录的同时会向上生成nginx(若没有的话)