Tengine安装

关于nginx是什么这里不进行赘述,这里安装的是Tengine,Tengine是nginx的封装加强版,由淘宝开源。下面进行编译安装。
(1)安装依赖

yum -y install gcc openssl-devel pcre-devel zlib-devel

(2)配置
相关配置参数说明:

./configure \   //安装的目录
--prefix=/usr \ //执行文件目录
--sbin-path=/usr/sbin/nginx \   //配置文件目录
一般只需要指定安装目录即可,执行文件目录和配置文件目录会默认在安装目录下面
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \  //这里配置用户和用户组,安装后只有该用户能够操作nginx
--group=nginx \
//nginx的模块是可插拔的,以下是需要编译安装的模块
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--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/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre

根据自己的配置,运行如下命令:

./configure \
  --prefix=/home/bxp/Documents/install/tengine-2.2.0/nginx \
  --error-log-path=/home/bxp/Documents/install/tengine-2.2.0/log/nginx/error.log \
  --http-log-path=/home/bxp/Documents/install/tengine-2.2.0/log/nginx/access.log \
  --pid-path=/home/bxp/Documents/install/tengine-2.2.0/run/nginx/nginx.pid  \
  --lock-path=/home/bxp/Documents/install/tengine-2.2.0/lock/nginx.lock \
  --with-http_ssl_module \
  --with-http_flv_module \
  --with-http_stub_status_module \
  --with-http_gzip_static_module \
  --http-client-body-temp-path=/home/bxp/Documents/install/tengine-2.2.0/tmp/nginx/client/ \
  --http-proxy-temp-path=/home/bxp/Documents/install/tengine-2.2.0/tmp/nginx/proxy/ \
  --http-fastcgi-temp-path=/home/bxp/Documents/install/tengine-2.2.0/tmp/nginx/fcgi/ \
  --http-uwsgi-temp-path=/home/bxp/Documents/install/tengine-2.2.0/tmp/nginx/uwsgi \
  --http-scgi-temp-path=/home/bxp/Documents/install/tengine-2.2.0/tmp/nginx/scgi \
  --with-pcre 

(3)安装

make && make install

(4)将nginx启动添加到系统服务
在/etc/init.d目录下创建nginx文件,加入以下内容:

#!/bin/bash 
# 
# nginx This shell script takes care of starting and stopping 
# standalone nginx 
# software version 2.1.2
# description: nginx service 
# processname: nginx 
# config file:

# Source function library. 
. /etc/rc.d/init.d/functions
#/home/bxp/Documents/install/tengine-2.2.0/nginx是nginx的安装目录
nginx="/home/bxp/Documents/install/tengine-2.2.0/nginx/sbin/nginx"
prog=$(basename $nginx)

#第一行是防止nginx自启动抛出异常80端口被占用,可自行修改默认端口号
#如果停止命令和开始命令是分开的,不在同一次执行,则不会出现异常
start(){   
#/home/bxp/Documents/install/tengine-2.2.0/nginx是nginx的安装目录
    chmod 755 /home/bxp/Documents/install/tengine-2.2.0/nginx/sbin/nginx
    /home/bxp/Documents/install/tengine-2.2.0/nginx/sbin/nginx
    echo "nginx start success"
}

stop(){
    pid=`ps -ef | grep "nginx" | grep -v "grep" | awk '{print $2}'`
    if [ -n "$pid" ]; then
 kill $pid
        echo "nginx stop success"
    else
        echo "no nginx service is running."
    fi
}

nginx_status() {
status $prog
}

restart(){
   stop
   start
}

case "$1" in
  start)
     start
  ;;
  stop)
     stop
  ;;
  status)
nginx_status
  ;;
  restart)
     restart
  ;;
  *)
     echo $"Usage: $0 {start|stop|status|restart}"
     exit 1
esac
exit

(5)启动/关闭nginx服务命令

systemctl start nginx
systemctl restart nginx
systemctl stop nginx

(6)测试
在浏览器中通过localhost进行测试。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值