安装openresty(源码)
安装前的准备
下载地址:https://openresty.org/download/openresty-1.21.4.1.tar.gz
RedHat、CENTOS用户
推荐您使用yum安装以下的开发库:
[root@nginx]# yum install pcre-devel openssl-devel gcc curl prel
离线安装开发库:需要找一台可以上网的服务器提前下载好并手动上传
[root@nginx]# yum install --downloadonly --downloaddir=/opt pcre-devel openssl-devel gcc cur prel #下载依赖包到/opt
将下载好的依赖包手动上传到内网主机,然后在内网主机rpm安装
[root@nginx]# rpm -ivh *.rpm --nodeps --force
构建 OpenResty
下载
从下载页 Download下载最新的 OpenResty® 源码包,并且像下面的示例一样将其解压:
[root@nginx]# tar zxvf openresty-1.21.4.1.tar.gz
./configure
然后在进入 openresty-1.21.4.1/
目录, 然后输入以下命令配置:
./configure
默认, --prefix=/usr/local/openresty
程序会被安装到/usr/local/openresty目录。
您可以指定各种选项,比如
[root@nginx]# ./configure --prefix=/home/openresty
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/home/openresty/nginx"
nginx binary file: "/home/openresty/nginx/sbin/nginx"
nginx modules path: "/home/openresty/nginx/modules"
nginx configuration prefix: "/home/openresty/nginx/conf"
nginx configuration file: "/home/openresty/nginx/conf/nginx.conf"
nginx pid file: "/home/openresty/nginx/logs/nginx.pid"
nginx error log file: "/home/openresty/nginx/logs/error.log"
nginx http access log file: "/home/openresty/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
cd ../..
Type the following commands to build and install:
gmake
gmake install
make
您可以使用下面的命令来编译:
[root@nginx]# make
如果您的电脑支持多核 make
工作的特性, 您可以这样编译:
[root@nginx]# make -j2
假设您是的机器是双核。
make install
如果前面的步骤都没有问题的话,您可以使用下面的命令安装 OpenResty 到您的系统中:
[root@nginx]# make install
查看并启动
[root@nginx]# /home/openresty/bin/openresty -V
nginx version: openresty/1.21.4.1
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
configure arguments: --prefix=/home/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.11 --with-ld-opt=-Wl,-rpath,/home/openresty/luajit/lib --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_ssl_module
[root@nginx]# /home/openresty/bin/openresty
[root@nginx]# ps aux |grep openresty
root 9278 0.0 0.0 55096 1656 ? Ss 17:56 0:00 nginx: master process /home/openresty/bin/openresty
root 11341 0.0 0.0 112812 984 pts/0 R+ 17:56 0:00 grep --color=auto openresty