下载所有包,jemalloc(可选)用于优化内存
yum groups install “Development 工具”- y yum -y  install bzip2 wget -c ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz wget -c http://www.openssl.org/source/openssl-1.0.2g.tar.gz wget -c http://www.zlib.net/zlib-1.2.11.tar.gz wget -c http://tengine.taobao.org/download/tengine-2.1.2.tar.gz # wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2 tar -zxf  pcre-8.40.tar.gz -C /usr/地方/src/tar -zxf  openssl-1.0.2g.tar.gz -C /usr/地方/src/tar -zxf  zlib-1.2.11.tar.gz , -C /usr/地方/src/tar -zxf  tengine-2.1.2.tar.gz -C /usr/地方/src/# tar jxvf  jemalloc-3.6.0.tar.bz2 -C /usr/地方/src/
1,安装pcre
mkdir /usr/地方/pcre cd /usr/地方/src/pcre - 8.40 。/configure ——prefix=/usr/地方/pcre make - j make 安装
2,安装openssl
mkdir /usr/地方/openssl cd /usr/地方/src/openssl-1.0.2g/?config ——prefix=/usr/地方/openssl make 依赖 make - j make 安装
vi/etc/profile
export 路径=$路径:/usr/地方/openssl/bin 或 echo “export 路径=$路径:/usr/地方/openssl/bin”,在祝辞,/etc/profile
: wq !
mkdir /usr/地方/zlib cd /usr/地方/src/zlib-1.2.11 。/configure ——prefix=/usr/地方/zlib make - j make 安装
4,安装Nginx
groupadd www useradd -g  www www  -s /bin/假的 cd /usr/地方/src/tengine-2.1.2/#开启jemalloc内存优化 。/configure ——prefix=/usr/地方/nginx ——without-http_memcached_module ——用户=www ——组=www ——with-http_stub_status_module ——with-http_ssl_module ——with-http_gzip_static_module ——使用openssl=/usr/地方/src/openssl-1.0.2g ——with-zlib=/usr/地方/src/zlib-1.2.11 ——with-pcre=/usr/地方/src/pcre - 8.40 -, - with-jemalloc=/usr/地方/src/jemalloc-3.6.0 使 make 安装
注意:——使用openssl=/usr/地方/src/openssl-1.0.2g——with-zlib=/usr/地方/src/zlib-1.2.11——with-pcre=/usr/地方/src/pcre - 8.40指向的是源码包解压的路径,而不是安装的路径,否则会报错
5,添加开机启动脚本
/usr/地方/nginx/sbin/nginx #启动nginx 设置nginx开机启动 vi 到/etc/摆在nginx #编辑启动文件添加下面内容 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # !/bin/sh # #,nginx 神却;能够script starts 以及stops 从而nginx 守护进程 # #,chkconfig:安康;85,15 描述:#还以为;Nginx  is an HTTP (S),服务器,HTTP (S), reverse \ #,proxy 以及IMAP/POP3 proxy 服务器 #,processname: nginx #,配置:/etc/nginx/nginx.conf #,配置:/usr/地方/nginx/conf/nginx.conf #,pidfile:/usr/地方/nginx/日志/nginx.pid #,Source function 图书馆。 只/etc/d/摆在/功能 #,Source networking 配置。 只/etc/sysconfig/网络 #,Check that  networking is 。 [,“网络”美元=,“不”,),,,exit 0 nginx="/usr/地方/nginx/sbin/nginx” 学监=$ (basename nginx美元) NGINX_CONF_FILE="/usr/地方/nginx/conf/nginx.conf” [/etc/sysconfig/, -f  nginx ),,,,只/etc/sysconfig/nginx lockfile=/var/锁定//nginx中高 make_dirs (), { #,make required 目录 用户=' nginx 美元;-V 2祝辞,1,|,grep “configure 参数:”,|,sed ’s/用户=\ [^ *)*——([^,]* \)。*/\ 1/g“,,” if [, -z “grep user 美元/etc/passwd’”,),然后 useradd -M  -s 美元/bin/nologin 用户 fi 选择=' nginx 美元;-V 2祝辞,1,|,grep “configure 参数:“ for opt 拷贝选项;美元做 if [, ' | echo opt 美元;grep ”。* -temp-path ' ',),然后 值=https://www.yisu.com/zixun/echo $选择|削减- d "=", -f 2》 if [!大敌;-d “价值”美元,];然后 #,echo “创造”,美元的价值 mkdir -p  value 美元;,,,chown -R user 美元价值 fi fi 完成 } start (), { [,-x nginx 美元],| |,exit 5 [,-f NGINX_CONF_FILE 美元],| |,exit 6 make_dirs echo -n $ " $掠夺:Starting ” daemon nginx 美元;-c  NGINX_CONF_FILE美元 retval=$ ? 回声 (美元,retval -eq 0,),,,, touch lockfile美元 return retval美元 } stop (), { echo -n $ " $掠夺:Stopping ” null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null nullcentos7.x编译安装淘宝tengine-2.1.2