Taobao Web server tengine under CentOS installation tutorial _nginx

Source: Internet
Author: User
Tags chmod lua openssl syslog

Note: Server environment is CentOS

First, Introduction

Tengine is a Web server project initiated by Taobao. Based on the Nginx, it adds a lot of advanced features and features to the needs of the large scale Web site. Tengine performance and stability has been in large sites such as Taobao, Day Cat Mall and so got a good test. Its ultimate goal is to build an efficient, stable, secure, easy-to-use Web platform.

From December 2011 onwards, Tengine became an Open-source project, and the Tengine team actively developed and maintained it. Tengine team members from the core of Taobao, Sogou and other Internet enterprises. Tengine is the result of Community cooperation, we welcome all of us to participate in it and contribute our own strength.

Second, characteristics

Inherit all the features of Nginx-1.2.9, 100% compatible with Nginx configuration;
Dynamic module loading (DSO) support. Adding a module no longer requires recompiling the entire tengine;
Input filter mechanism support. By using this mechanism Web application firewall is more convenient to write;
Dynamic scripting language LUA support. Extended functionality is very efficient and simple;
Support Pipeline (pipe) and syslog (local and remote) forms of log and log sampling;
An access request that combines multiple CSS and JavaScript files becomes a request;
More powerful load balancing ability, including consistency hash module, session Maintenance module, but also to the back-end of the server for active health check, according to the server status of automatic on-line offline;
Automatically sets the number of processes and binding CPU affinity based on the number of CPUs;
Monitor the system's load and resource occupancy to protect the system;
Show more friendly error messages to operators to locate faulty machines;
More powerful anti-attack (access speed limit) module;
More convenient command-line parameters, such as listing the compiled module list, supported instructions, and so on;
You can set an expiration time based on the Access file type;

Third, installation

1.yum Installation

Yum installation is relatively simple, the configuration of a good source after the direct yum install can be.
① configuration of Third-party yum sources (centos default source is not Nginx software package)

Copy Code code as follows:
Yum Install wget #安装下载工具wget
wget http://www.atomicorp.com/installers/atomic #下载atomic Yum Source
Sh./atomic #安装
Yum Check-update #更新yum软件包

② installation Configuration
Copy Code code as follows:
Yum install Nginx #安装nginx, according to the prompts, the input y installation can be successfully installed
Service Nginx Start #启动
Chkconfig Nginx on #设为开机启动
/etc/init.d/nginx Restart #重启
rm-rf/usr/share/nginx/html/* #删除ngin默认测试页

2. The source code compiles installs

Source code installation is slightly more complex, there are some dependent packages need to be compiled separately
Source installation can choose either the original Nginx can also use Taobao modified Tengine, here is recommended to use Tengin,tengine fully compatible nginx and add a lot of new features, suitable for increasingly complex business expansion.
Tengine Official website: http://tengine.taobao.org/
① first installs Pcre to support Nginx pseudo static

Copy Code code as follows:

# CD/USR/LOCAL/SRC
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
# tar ZXVF pcre-8.21.tar.gz
# Mkdir/usr/local/pcre #创建安装目录
# CD pcre-8.21
#./configure--prefix=/usr/local/pcre #配置
# make
# make Install

② installation Tengine

Copy Code code as follows:

# CD/USR/LOCAL/SRC
# wget http://tengine.taobao.org/download/tengine-1.4.2.tar.gz
# tar ZXVF tengine-1.4.2.tar.gz
# CD Tengine
#./configure--prefix=/usr/local/nginx--with-http_stub_status_module--with-pcre=/usr/local/src/pcre-8.21

# make
# make Install
#/usr/local/nginx/sbin/nginx #启动nginx
# chown Nobody.nobody-r/usr/local/nginx/html
# chmod 700-r/usr/local/nginx/html


Note:--with-pcre=/usr/local/src/pcre-8.21 points to the source package decompression path, rather than the installation path, otherwise it will be an error.

③ Setup Tengine boot

Copy Code code as follows:
# Vi/etc/rc.d/init.d/nginx #编辑启动文件添加下面内容

#!/bin/bash
# tengine Startup script# 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 are up.
[${networking} = "No"] && exit 0
[x $nginxd] | | Exit 0
# Start Nginx daemons functions.
Start () {
If [-e $nginx _pid];then
echo "Tengine 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/usr/local/nginx/logs/nginx.pid
}
Reload () {
Echo-n $ "Reloading $prog:"
#kill-hup ' Cat ${nginx_pid} '
Killproc $nginxd-hup
Retval=$?
Echo
}
# How we were called.
Case "$" 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

Save exit

Copy Code code as follows:

# chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限
# chkconfig Nginx on #设置开机启动
#/etc/rc.d/init.d/nginx Restart


At this point, the Nginx installation is complete. Here again why to use Taobao's tengine:
1. Inherit all the features of Nginx, 100% compatible with Nginx configuration;
2. Dynamic module loading (DSO) support. Adding a module no longer requires recompiling the entire tengine;
3. Input filter mechanism support. By using this mechanism Web application firewall is more convenient to write;
4. Dynamic scripting language LUA support. Extended functionality is very efficient and simple;
5. Support Pipeline (pipe) and syslog (local and remote) forms of log and log sampling;
6. Combination of multiple CSS, JavaScript file access request to become a request;

Four, the Success page

After installing and starting the Tengine, the browser enters the IP address and the following illustration shows that the installation was successful.

V. Matters of attention

1.–WITH-OPENSSL=/USR/LOCAL/SRC/OPENSSL-1.0.1E This step may be wrong, note: –with-openssl=/usr/local/src/openssl-1.0.1e Point is the source package decompression path, rather than install the path, otherwise will be an error, download, extract the source package, as follows:

Copy Code code as follows:

Cd/usr/local/src
wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
Tar zxvf openssl-1.0.1e

Then perform the Tengine installation again.


2.–with-pcre=/usr/local/src/pcre-8.33 Point is the source package decompression path, not the installation path, otherwise it will be an error.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.