centos6安装openresty

前端之家收集整理的这篇文章主要介绍了centos6安装openresty前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、安装依赖库

yum install readline-devel pcre-devel openssl-devel gcc

2、下载openresty

wget --no-check-certificate https://openresty.org/download/openresty-1.11.2.2.tar.gz

3、解压文件

tar xzvf openresty-1.11.2.2.tar.gz

4、进入解压目录,

cd openresty-1.11.2.2

5、安装在/usr/local/openresty目录

./configure --prefix=/usr/local/openresty

6、make

make

7、make install

make install

8、设置环境变量

vi /etc/profile
加下面代码 
PATH=/usr/local/openresty/Nginx/sbin:$PATH
export PATH
让修改的环境变量生效
source /etc/profile 
9、查看版本
Nginx -v

如果出现Nginx version: openresty/1.11.2.2,则安装成功

10、设置Nginx为服务和开机启动

vi /etc/rc.d/init.d/Nginx

#!/bin/bash
# Tengine Startup script# processname: Nginx
# chkconfig: - 85 15
# description: Nginx is a World Wide Web server. It is used to serve
# pidfile: /var/run/Nginx.pid
# config: /usr/local/Nginx/conf/Nginx.conf
Nginxd=/usr/local/openresty/Nginx/sbin/Nginx
Nginx_config=/usr/local/openresty/Nginx/conf/Nginx.conf
Nginx_pid=/usr/local/openresty/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 "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
}
# 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

11、保存退出

chmod 775 /etc/rc.d/init.d/Nginx   #赋予文件执行权限
chkconfig  --level 012345 Nginx on   #设置开机启动
service Nginx start 

猜你在找的CentOS相关文章