linux下tengine编译安装及自启动配置
2017-07-21 09:41
344 查看
1、解压
tar -zxvf tengine-2.1.0.tar.gz
2、测试编译环境
解压完成后进入tengine-2.1.0目录,
如果没安装依赖请先安装依赖:yum -y install gcc openssl-devel pcre-devel zlib-devel
创建client目录,也可以在启动Nginx时再创建:mkdir -p /var/tmp/nginx/client/
测试安装环境:
./configure \
--prefix=/opt/soft/tengine-2.1.0/ \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
3、编译安装:make && make install
4、创建自启动脚本
vi /etc/init.d/nginx
添加以下内容,根据自己安装路径修改标红的两处路径即可:
#!/bin/bash
#
# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/opt/soft/tengine-2.1.0/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/opt/soft/tengine-2.1.0/conf/nginx.conf"
#[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
#make_dirs() {
# # make required directories
# user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
# options=`$nginx -V 2>&1 | grep 'configure arguments:'`
# for opt in $options; do
# if [ `echo $opt | grep '.*-temp-path'` ]; then
# value=`echo $opt | cut -d "=" -f 2`
# if [ ! -d "$value" ]; then
# # echo "creating" $value
# mkdir -p $value && chown -R $user $value
# fi
# fi
# done
#}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
# make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
# -HUP是nginx平滑重启参数
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
exit $RETVAL
5、修改刚创建的/etc/init.d/下nginx脚本的权限
chmod 755 nginx
service nginx start 即可启动nginx
6、加入系统服务,设置自启动
chkconfig --add nginx
chkconfig nginx on
tar -zxvf tengine-2.1.0.tar.gz
2、测试编译环境
解压完成后进入tengine-2.1.0目录,
如果没安装依赖请先安装依赖:yum -y install gcc openssl-devel pcre-devel zlib-devel
创建client目录,也可以在启动Nginx时再创建:mkdir -p /var/tmp/nginx/client/
测试安装环境:
./configure \
--prefix=/opt/soft/tengine-2.1.0/ \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre
3、编译安装:make && make install
4、创建自启动脚本
vi /etc/init.d/nginx
添加以下内容,根据自己安装路径修改标红的两处路径即可:
#!/bin/bash
#
# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/opt/soft/tengine-2.1.0/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/opt/soft/tengine-2.1.0/conf/nginx.conf"
#[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
#make_dirs() {
# # make required directories
# user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
# options=`$nginx -V 2>&1 | grep 'configure arguments:'`
# for opt in $options; do
# if [ `echo $opt | grep '.*-temp-path'` ]; then
# value=`echo $opt | cut -d "=" -f 2`
# if [ ! -d "$value" ]; then
# # echo "creating" $value
# mkdir -p $value && chown -R $user $value
# fi
# fi
# done
#}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
# make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
# -HUP是nginx平滑重启参数
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
exit $RETVAL
5、修改刚创建的/etc/init.d/下nginx脚本的权限
chmod 755 nginx
service nginx start 即可启动nginx
6、加入系统服务,设置自启动
chkconfig --add nginx
chkconfig nginx on
相关文章推荐
- linux下tengine2.2.0编译安装、开机启动、反向代理配置及健康检查
- tengine2.2.0编译安装、开机启动、反向代理配置及健康检查
- Linux(centos) 编译安装 Mysql 后配置开机自动启动
- nginx(tengine)编译安装启动配置
- Boost下载安装编译配置使用指南(含Windows和Linux)
- Resin安装,配置和在Linux上的自动启动问题
- JBoss的安装与配置(二)Linux(RedHat4)中JBoss自动启动设置
- Boost下载安装编译配置使用指南(含Windows和Linux)
- 【原】Boost下载安装编译配置使用指南(含Windows、Linux以及ARM Linux)
- VMware 6 Linux 版本下载安装配置编译序列号注册码
- 深入理解Linux软件包的配置、编译与安装
- linux下mysql二进制编译安装并开机启动
- Boost下载安装编译配置使用指南(含Windows和Linux)
- linux下网路启动服务器安装和配置方法(pxe+tftp+dhcpd)
- Boost下载安装编译配置使用指南(含Windows和Linux)
- Boost下载安装编译配置使用指南(含Windows和Linux)
- 整理的linux下ntop启动、安装、配置、使用!
- Linux下MySQL的编译安装和简单配置
- 深入理解Linux软件包的配置、编译与安装
- Linux下让编译安装的Apache自动启动