网站首页 > 技术教程 正文
1、安装必要的编译环境好
由于Tengine安装需要使用源代码自行编译,所以在安装前需要安装必要的编译工具:
# yum update # yum install gcc gcc-c++ autoconf automake 1 2
2、安装需要的组件
A、PCRE
PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx rewrite依赖于PCRE库,所以在安装Tengine前一定要先安装PCRE,最新版本的PCRE可在官网(http://www.pcre.org/)获取。具体安装流程为:
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 1 2 3 4 5 6
附加信息:
源码的安装一般由3个步骤组成:配置(configure)、编译(make)、安装(make install)。
Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./configure –help输出详细的选项列表。其中–prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share,比较凌乱。
如果配置–prefix,如:./configure –prefix=/usr/local/test,可以把所有资源文件放在/usr/local/test的路径中,不会杂乱。
用了—prefix选项的另一个好处是卸载软件或移植软件。当某个安装的软件不再需要时,只须简单的删除该安装目录,就可以把软件卸载得干干净净;移植软件只需拷贝整个目录到另外一个机器即可(相同的操作系统)。当然要卸载程序,也可以在原来的make目录下用一次make uninstall,但前提是make文件指定过uninstall。
B、OpenSSL
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。,安装OpenSSL(http://www.openssl.org/source/)主要是为了让tengine支持Https的访问请求。具体是否安装看需求。
复制代码 代码如下:
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 1 2 3 4 5 6
C、Zlib
Zlib是提供资料压缩之用的函式库,当Tengine想启用GZIP压缩的时候就需要使用到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 1 2 3 4 5 6
D、jemalloc
jemalloc(http://www.canonware.com/jemalloc/)是一个更好的内存管理工具,使用jemalloc可以更好的优化Tengine的内存管理。
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 1 2 3 4 5 6
3、安装Tengine
在主要核心的组件安装完毕以后就可以安装Tegine了,最新版本的Tegine可从官网(http://tengine.taobao.org/)获取。
在编译安装前还需要做的一件事是添加一个专门的用户来执行Tengine。当然你也可以用root(不建议)。
复制代码 代码如下:
groupadd www-data useradd -s /sbin/nologin -g www-data www-data 1 2
接下来才是进行安装:
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 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
注意配置的时候 –with-pcre 、–with-openssl、–with-jemalloc、–with-zlib的路径为源文件的路径。
4、配置Tengine,设置tengine自动启动
vim /etc/rc.d/init.d/nginx
编辑启动文件添加下面内容
#!/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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
保存退出
复制代码 代码如下:
chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限
chkconfig nginx on #设置开机启动
service nginx restart #启动服务
猜你喜欢
- 2024-10-12 webserver神器 nginx安装(webmin nginx)
- 2024-10-12 Nginx学习笔记(nginx从入门到实践)
- 2024-09-26 CentOS7搭建nginx环境(centos7搭建http)
- 2024-09-26 CentOS7.3安装配置Nginx教程(centos7安装详细图解配置ip)
- 2024-09-26 135页阿里云OSS运维基础实战手册,图文结合一看就懂,仅分享2天
- 2024-09-26 Centos 6.5部署nginx+php环境部署
- 2024-09-26 nginx负载均衡配置(nginx负载均衡配置,当前机器宕机)
- 2024-09-26 Openresrt最佳案例 | 第1篇:Nginx介绍
- 2024-09-26 nginx 源码安装并开启gzip静态压缩
- 2024-09-26 记录一次nginx升级,支持ipv4和ipv6访问https
欢迎 你 发表评论:
- 12-17禁用usb接口(禁用usb接口怎么解除)
- 12-17win10重启黑屏进不去(windows10重启黑屏)
- 12-17产品密钥怎么输入0和1(产品密钥的格式)
- 12-17怎么安装微信到手机上(怎么安装微信到手机上下载微信)
- 12-17卡巴斯基杀毒软件手机版免费下载
- 12-17联想中国驱动下载(联想驱动下载网址)
- 12-17苹果设置下载安装(苹果设置下载安装安卓)
- 12-17笔记本电脑打不开机什么原因
- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)

本文暂时没有评论,来添加一个吧(●'◡'●)