Centos 6.10 Install openresty-1.13.6.2

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hanzheng260561728/article/details/81669161

Nginx conf配置参考https://blog.csdn.net/hanzheng260561728/article/details/80583051

依赖安装
yum install -y wget gcc gcc-c++ readline-devel zlib zlib-devel pcre pcre-devel openssl openssl-devel tcl perl postgresql-libs postgresql-devel

安装LuaJIT
cd /usr/local/software
wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar zxvf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make && make install

设置环境变量
vi /etc/profile
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0

刷新
source /etc/profile

安装OpenResty
wget --no-check-certificate https://openresty.org/download/openresty-1.13.6.2.tar.gz
tar -xzvf openresty-1.13.6.2.tar.gz
cd openresty-1.13.6.2/
./configure --prefix=/usr/local/openresty --with-luajit --with-http_postgres_module --with-http_iconv_module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_realip_module --with-stream --with-stream_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_dav_module --with-http_sub_module  --with-http_gunzip_module --with-pcre --with-debug
gmake
gmake install


设置Nginx为服务和开机启动
vi /etc/rc.d/init.d/nginx
#!/bin/bash
# chkconfig: - 18 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings

NGINX_SBIN=" /usr/local/openresty/nginx/sbin/nginx"
NGINX_CONF="/usr/local/openresty/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/openresty/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"

#Source networking configuration
. /etc/sysconfig/network
# Check networking is up
[ ${NETWORKING} = "no" ] && exit 0
[ -x $NGINX_SBIN ] || exit 0

start() {
        echo -n $"Starting $prog: "
        touch /var/lock/subsys/nginx
        daemon $NGINX_SBIN -c $NGINX_CONF
        RETVAL=$?
        echo
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -TERM
        rm -rf /var/lock/subsys/nginx /var/run/nginx.pid
        RETVAL=$?
        echo
        return $RETVAL
}

reload(){
        echo -n $"Reloading $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

restart(){
        stop
        start
}

configtest(){
    $NGINX_SBIN -c $NGINX_CONF -t
    return 0
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload)
        reload
        ;;
  restart)
        restart
        ;;
  configtest)
        configtest
        ;;
  *)
        echo $"Usage: $0 {start|stop|reload|restart|configtest}"
        RETVAL=1
esac

exit $RETVAL


设置环境变量
vi /etc/profile
export PATH=/usr/local/openresty/nginx/sbin:$PATH

刷新
source /etc/profile

或者

创建nginx软连接
ln -s /usr/local/openresty/nginx/sbin/* /usr/local/sbin/

赋予文件执行权限
chmod 775 /etc/rc.d/init.d/nginx   

开机启动
chkconfig nginx on  
chkconfig --add nginx
service nginx start

猜你喜欢

转载自blog.csdn.net/hanzheng260561728/article/details/81669161