gentoo中安装tengine

今天有时间折腾了一下tengine,终于在gentoo中把nginx切换成了tengine。没有用tengine的默认配置,使用了gentoo中编译nginx的参数及路径。过程如下:

1、下载tengine

地址:http://tengine.taobao.org/download/tengine-1.4.2.tar.gz

2、解压

tar -xvf tengine-1.4.2.tar.gz

3、编译安装(按照gentoo中的nginx编译参数配置)

cd tengine-1.4.2
./configure --prefix=/usr --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error_log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access_log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-scgi-temp-path=/var/tmp/nginx/scgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
make
make install

4、启动项及设置开机启动

vi /etc/init.d/nginx

添加(gentoo的/etc/init.d/nginx):

#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/nginx/files/nginx.initd,v 1.2 2012/07/18 18:59:46 hollow Exp $

extra_commands="configtest"
extra_started_commands="upgrade reload"

description="Robust, small and high performance http and reverse proxy server"
description_configtest="Run nginx' internal config check."
description_upgrade="Upgrade the nginx binary without losing connections."
description_reload="Reload the nginx configuration without losing connections."

nginx_config="/etc/nginx/nginx.conf"

command="/usr/sbin/nginx"
command_args="-c ${nginx_config}"
pidfile=${pidfile:-/var/run/nginx.pid}

depend() {
	need net
	use dns logger netmount
}

start_pre() {
	if [ "${RC_CMD}" != "restart" ]; then
		configtest || return 1
	fi
}

stop_pre() {
	if [ "${RC_CMD}" = "restart" ]; then
		configtest || return 1
	fi
}

stop_post() {
	rm -f ${pidfile}
}

reload() {
	configtest || return 1
	ebegin "Refreshing nginx' configuration"
	kill -HUP `cat ${pidfile}` &>/dev/null
	eend $? "Failed to reload nginx"
}

upgrade() {
	configtest || return 1
	ebegin "Upgrading nginx"

	einfo "Sending USR2 to old binary"
	kill -USR2 `cat ${pidfile}` &>/dev/null

	einfo "Sleeping 3 seconds before pid-files checking"
	sleep 3

	if [ ! -f ${pidfile}.oldbin ]; then
		eerror "File with old pid not found"
		return 1
	fi

	if [ ! -f ${pidfile} ]; then
		eerror "New binary failed to start"
		return 1
	fi

	einfo "Sleeping 3 seconds before WINCH"
	sleep 3 ; kill -WINCH `cat ${pidfile}.oldbin`

	einfo "Sending QUIT to old binary"
	kill -QUIT `cat ${pidfile}.oldbin`

	einfo "Upgrade completed"
	eend $? "Upgrade failed"
}

configtest() {
	mkdir -p /var/log/nginx || return 1
	mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,scgi,uwsgi} || return 1

	ebegin "Checking nginx' configuration"
	${command} -c ${nginx_config} -t -q

	if [ $? -ne 0 ]; then
		${command} -c ${nginx_config} -t
	fi

	eend $? "failed, please correct errors above"
}

开机启动

rc-update add nginx default

完成,测试一下:

nginx -v
Tengine version: Tengine/1.4.2 (nginx/1.2.5)

已经把笔记本和局域网的gentoo服务器都换了,vps中的也换了,虽然对性能提升基本没什么影响,但对于国产开源软件,支持一下。。。

发表评论

电子邮件地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据