参考文档:https://www.aliyun.com/jiaocheng/790120.html
进入安装目录:
cd /usr/local/
下载依赖:
yum install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perlreadline-devel pcre-devel openssl-devel gcc
一般情况下,gcc,openssl-devel,pcre-devel 是必须的,也是软件库里 必备的,其他的能不能下载,随缘
下载并解压openresty(注意你此时的位置在 /usr/local)
Wget https://openresty.org/download/openresty-1.11.2.3.tar.gz tar -xzvf openresty-1.11.2.3.tar.gz
安装LuaJIT
cd openresty-1.11.2.3/bundle/LuaJIT-2.1-20170405 make clean && make && make install ln -sf LuaJIT-2.1-20170405 /usr/local/bin/luajit
下载ngx_cache_purge模块 ,该模块用于清理nginx缓存
cd /usr/servers/openresty-1.11.2.3/bundle wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz tar -xvf 2.3.tar.gz
下载nginx_upstream_check_module模块 ,该模块用于ustream健康检查
cd /usr/servers/openresty-1.11.2.3/bundle wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz tar -xvf v0.3.0.tar.gz
安装OpenResty
cd /usr/servers/openresty-1.11.2.3
/configure --prefix=/usr/servers --with-http_realip_module--with-pcre--with-luajit --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
不出意外的话,会报错:--with-http_realip_module--with-pcre--with-luajit会出错,那就使用下面的语句
./configure --prefix=/usr/servers --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
make && make install
其他 (可忽略)1.核心和第三方模块目录openresty-1.11.2.3/bundle
Nginx启动
(查找一下nginx/sbin所在的路径:find / -name nginx ,本文中是:/usr/local/nginx/sbin)
先使用优雅重启
[if !supportLists]1. [endif] cd /usr/local/nginx/sbin/
[if !supportLists]2. [endif] ./nginx -s reload
当报错为:nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
使用下面的方法启动nginx:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
网友评论