How to install Tengine in CentOS 6.6

Source: Internet
Author: User
Tags bz2 openssl centos


Tengine was introduced in previous articles. Previously, it only used the content configured by the O & M personnel, but did not install and configure it on its own. Tengine was installed on a trial basis. Record the following information for further improvement.

The Tengine official website has a very simple tutorial, which does not involve some common settings, so it is for reference only. The installation steps and processes for me one afternoon.

1. Install the necessary compiling environment.

Because Tengine installation requires source code compilation, you need to install the necessary compilation tools before installation:

Shell

# Yum update
# Yum install gcc-c ++ autoconf automake

2. Install required components

A. PCRE

PCRE (Perl Compatible Regular Expressions) is a Perl library, including a perl-Compatible Regular expression library. Nginx rewrite depends on the PCRE library, so you must first install PCRE before installing Tengine, the latest version of PCRE can be obtained on the official website (http://www.pcre.org. The installation process is as follows:


Cd/usr/local/src
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
Tar zxvf pcre-8.36.tar.gz
Cd pcre-8.36
./Configure -- prefix =/usr/local/pcre
Make & make install

Additional information:

The installation of source code is generally composed of three steps: Configuration (configure), compilation (make), and installation (make install ).
Configure is an executable script with many options. Use the command./configure-help in the source code path to be installed to output a detailed list of options. The-prefix option is the installation path. If this option is not configured, the executable file is stored in/usr/local/bin by default, by default, library files are stored in/usr/local/lib, configuration files are stored in/usr/local/etc by default, and other resource files are stored in/usr/local/share, which is messy.
If you configure-prefix, such as./configure-prefix =/usr/local/test, you can put all the resource files in the path of/usr/local/test without clutter.
Another benefit of using the-prefix option is to uninstall or port the software. When a software installation is no longer needed, you only need to delete the installation directory to clean the software; to transplant software, you only need to copy the entire directory to another machine (the same operating system ). Of course, to uninstall the program, you can also use make uninstall in the original make Directory, provided that the make file has specified uninstall.
B. OpenSSL

OpenSSL is a powerful Secure Socket-Layer cryptographic library that includes major cryptographic algorithms, common keys, certificate encapsulation management functions, and SSL protocols, and provides a wide range of applications for testing or other purposes ., The installation of OpenSSL (http://www.openssl.org/source/) is primarily intended to allow tengine to support Https access requests. Whether to install or not depends on the requirements.

Cd/usr/local/src
Wget http://www.openssl.org/source/openssl-1.0.2.tar.gz
Tar zxvf openssl-1.0.2.tar.gz
Cd openssl-1.0.2.tar.gz
./Configure -- prefix =/usr/local/openssl
Make & make install

C, Zlib

Zlib is a library that provides data compression. When Tengine wants to enable GZIP compression, it needs to use Zlib (http://www.zlib.net /).

Cd/usr/local/src
Wget http://zlib.net/zlib-1.2.8.tar.gz
Tar zxvf zlib-1.2.8.tar.gz
Cd zlib-1.2.8.tar.gz
./Configure -- prefix =/usr/local/zlib
Make & make install

D. jemalloc

Jemalloc (http://www.canonware.com/jemalloc/) is a better memory management tool, using jemalloc can better optimize Tengine memory management.


Cd/usr/local/src
Wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
Tar jxvf jemalloc-3.6.0.tar.bz2
Cd jemalloc-3.6.0.tar.bz2
./Configure -- prefix =/usr/local/jemalloc
Make & make install

3. Install Tengine

After the installation of the main core components can install Tegine, the latest version of Tegine can be obtained from the official website (http://tengine.taobao.org.

One thing that needs to be done before compilation and installation is to add a dedicated user to execute Tengine. Of course, you can also use root (not recommended ).

Groupadd www-data
Useradd-s/sbin/nologin-g www-data

Next, install:


Cd/usr/local/src
Wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
Tar-zxvf tengine-2.1.0.tar.gz
Cd tengine-2.1.0
./Configure -- prefix =/usr/local/nginx \
-- User = www-data \
-- Group = www-data \
-- With-pcre =/usr/local/src/pcre-8.36 \
-- With-openssl =/usr/local/src/openssl-1.0.2 \
-- With-jemalloc =/usr/local/src/jemalloc-3.6.0 \
With-http_gzip_static_module \
With-http_realip_module \
With-http_stub_status_module \
With-http_concat_module \
-- With-zlib =/usr/local/src/zlib-1.2.8
Make & make install
Note that the paths-with-pcre,-with-openssl,-with-jemalloc, and-with-zlib are the source file paths during configuration.

4. Configure Tengine and set tengine to automatically start


# Vim/etc/rc. d/init. d/nginx
# Edit the startup file and add the following content
#! /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/usr/local/nginx/logs/nginx. pid
}
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


Save and exit


Chmod 775/etc/rc. d/init. d/nginx # grant the file execution permission
Chkconfig nginx on # set startup
Service nginx restart # start the service
.

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.