Nginx Installation - Tengine

Keywords: Nginx zlib Web Server yum

Tengine is a Web server project initiated by Taobao.com. On the basis of Nginx, it adds many advanced functions and features to meet the needs of large-scale visiting websites. Tengine's performance and stability have been well tested on large websites such as Taobao and Tianmao. Its ultimate goal is to build an efficient, stable, secure and easy-to-use Web platform.

Tengine is fully compatible with Nginx, so you can configure Tengine by referring to Nginx.

I. Getting Installation Packages

wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz

II. Installation Dependency Package

yum install pcre pcre-devel zlib zlib-devel open openssl-devel gcc gcc-c++

Configuration of Nginx

    ./configure \
    --prefix=/usr/local/nginx \
    --pid-path=/usr/local/nginx/logs/nginx.pid \
    --error-log-path=/usr/local/logs/error.log \
    --http-log-path=/usr/local/logs/access.log \
    --with-http_gzip_static_module \
    --http-client-body-temp-path=/var/temp/nginx/client \
    --http-proxy-temp-path=/var/temp/nginx/proxy \
    --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
    --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
    --http-scgi-temp-path=/var/temp/nginx/scgi


    Preix=/usr/local/nginx#nginx installation path, which is the default and can be changed by itself
    --pid-path=/usr/local/nginx/logs/nginx.pid\\nginx process file
    --error-log-path=/usr/local/logs/error.log\ nginx process error log
    --http-log-path=/usr/local/logs/access.log\\\\\ nginx service log file
    With-http_gzip_static_module\ nginx, gzip module
 Some module configurations are installed at / var/temp/nginx, so create the / var/temp/nginx directory beforehand

Compilation & Installation

make;make install

5. Start, Stop, Reload Configuration File Command

1. Start: Run nginx Execution File directly

[root@localhost]/usr/local/nginx/sbin# ./nginx 
[root@localhost]/usr/local/nginx/sbin# ps -aux|grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      38247  0.0  0.1  46836  1124 ?        Ss   13:40   0:00 nginx: master process ./nginx
nobody    38248  0.0  0.1  47276  1768 ?        S    13:40   0:00 nginx: worker process
root      38251  0.0  0.0 103260   848 pts/1    S+   13:40   0:00 grep nginx

You can use - c to specify configuration files at startup

[root@localhost]/usr/local/nginx# sbin/nginx -c conf/nginx.conf
[root@localhost]/usr/local/nginx# ps -aux|grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      38450  0.0  0.1  46836  1124 ?        Ss   14:02   0:00 nginx: master process sbin/nginx -c conf/nginx.conf
nobody    38451  0.0  0.1  47276  1768 ?        S    14:02   0:00 nginx: worker process        
root      38453  0.0  0.0 103260   848 pts/1    S+   14:02   0:00 grep nginx

2. Slow stop:. / nginx-s quit until the current work is done

[root@localhost]/usr/local/nginx/sbin# ./nginx -s quit
[root@localhost]/usr/local/nginx/sbin# ps -aux|grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      38258  0.0  0.0 103260   844 pts/1    S+   13:43   0:00 grep nginx

3. Stop Violence:. / nginx-s stop or directly kill nginx Pid nginx Pid as nginx process number, which can be viewed in nginx/logs/nginx.pid

[root@localhost]/usr/local/nginx/sbin# ./nginx -s stop
[root@localhost]/usr/local/nginx/sbin# ps -aux |grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      38272  0.0  0.0 103260   848 pts/1    S+   13:46   0:00 grep nginx
[root@localhost]/usr/local/nginx/sbin# 
[root@localhost]/usr/local/nginx/logs# ps -aux|grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      38287  0.0  0.1  46836  1124 ?        Ss   13:47   0:00 nginx: master process ../sbin/nginx
nobody    38288  0.0  0.1  47276  1768 ?        S    13:47   0:00 nginx: worker process
root      38294  0.0  0.0 103260   848 pts/1    S+   13:48   0:00 grep nginx
[root@localhost]/usr/local/nginx/logs# kill $(cat nginx.pid)
[root@localhost]/usr/local/nginx/logs# ps -ef|grep nginx
root      38298   2255  0 13:48 pts/1    00:00:00 grep nginx

4. Reload configuration

[root@localhost]/usr/local/nginx/sbin# ./nginx -s reload

6. Set up boot-up and start-up

1. vi/etc/init.d/nginx (enter the following code)

#!/bin/bash
# nginx Startup script for the Nginx HTTP  Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a  high-performance web and proxy server.
#              It has a lot of features, but  it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config:  /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ]  && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
    echo "nginx already running...."
    exit 1
fi
    echo -n $"Starting $prog: "
    daemon $nginxd -c ${nginx_config}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
    return $RETVAL
}
# Stop nginx daemons functions.
stop() {
         echo -n $"Stopping $prog: "
         killproc $nginxd
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx  /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
     echo -n $"Reloading $prog: "
     #kill -HUP `cat ${nginx_pid}`
     killproc $nginxd -HUP
     RETVAL=$?
     echo
}
# See how we were called.
case "$1" in
start)
         start
         ;;
stop)
         stop
         ;;
reload)
         reload
         ;;
restart)
         stop
         start
         ;;
status)
         status $prog
         RETVAL=$?
         ;;
*)
         echo $"Usage: $prog {start|stop|restart|reload|status|help}"
         exit 1
esac
exit $RETVAL

2. Change Execution Permissions

Chmod a+x/etc/init.d/nginx (a+x==> all users can execute)

3. Add to / etc/rc.local to realize boot-up self-start

vi /etc/rc.local
Add any line: / etc/init.d/nginx start
Save out: wq

4. Operation method of console

[root@localhost]/usr/local/nginx# service nginx start
 Starting nginx: [OK]
[root@localhost]/usr/local/nginx# service nginx restart
 Stop nginx: [Determine]
Starting nginx: [OK]
[root@localhost]/usr/local/nginx# service nginx reload
 Reload nginx:[OK]
[root@localhost]/usr/local/nginx# service nginx stop
 Stop nginx: [Determine]

Posted by wangsc66 on Sun, 21 Apr 2019 19:21:34 -0700