参考:
https://openresty.org/en/installation.html
https://openresty.org/en/installation.html#building-openresty
1.前期依赖库安装:
yum install -y make cmake gcc curl
yum install -y prel pcre-devel
yum install -y openssl openssl-devel
# mkdir -p /opt/software/openresty
2.下载:
# wget https://openresty.org/download/openresty-1.17.8.2.tar.gz
3.解压:
# tar -zxvf openresty-1.17.8.2.tar.gz -C /opt/software/openresty/
# cd /opt/software/openresty/openresty-1.17.8.2/
4.编译:
# ./configure --prefix=/usr/local/openresty
默认, --prefix=/usr/local/openresty 程序会被安装到/usr/local/openresty目录。
(<openresty-prefix> is default to /usr/local/openresty/ unless being overridden by ./configure's --prefix=PATH option).
编译成功提示:
Type the following commands to build and install:
gmake
gmake install
也可以携带模块参数等安装,如:
# ./configure --prefix=/usr/local/openresty --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
5.安装:
# make -- 还可以根据CPU核数添加 j参数,比如两核:j2
# sudo make install
sed -e "s|%%PREFIX%%|/usr/local/openresty/nginx|" \
环境变量:
export PATH=/usr/local/openresty/bin:/usr/local/openresty/nginx/sbin:$PATH
官方建议:
# better also add the following line to your ~/.bashrc or ~/.bash_profile file.
export PATH=/usr/local/openresty/bin:$PATH
6.配置:
cd /usr/local/openresty/nginx/conf
vim nginx.conf
或者直接:vim /usr/local/openresty/nginx/conf/nginx.conf
开放root权限,在文件顶部添加:user root root;
查看版本:
# /usr/local/openresty/bin/openresty -V
nginx version: openresty/1.17.8.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
7.启动:
# /usr/local/openresty/bin/openresty
查看启动进程:ps aux |grep openresty
8.访问:
# curl 127.0.0.1
显示:Welcome to OpenResty!
安装成功!
Welcome to OpenResty!
If you see this page, the OpenResty web platform is successfully installed and working. Further configuration is required.