javaWeb学习

Centos 7.3 下安装最新OpenResty 1.17.8

2020-07-07  本文已影响0人  小钟钟同学

全新的服务器,需要做相关的负载依赖的时候,原本想直接安装nginx,但基于先用一些业务场景可能会用到,比如限流等,所以最终还是选择的了OpenResty 。
参考:https://www.runoob.com/w3cnote/openresty-intro.html

第1步:OpenResty相关依赖的安装

 yum -y install readline-devel pcre-devel openssl-devel gcc postgresql-devel
yum install -y epel-release
yum install -y gcc gcc-c++ curl
yum install -y libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl 

第2步:安装其他工具

yum install -y nano wget

第3步:创建存放使用wget下载相关安装包的路径

mkdir - p /data/bak
cd /data/bak

第4步:下载最新的版本 并解压

wget http://openresty.org/download/openresty-1.17.8.1.tar.gz
tar -xzvf openresty-1.17.8.1.tar.gz 

第5步:编译configure 相关的配置,根据相关需求配置相关的依赖模块

最简单的版本

./configure
make 
make install
或
gmake 
gmake install

我的配置:

./configure --prefix=/usr/local/openresty --with-luajit --with-pcre --with-http_ssl_module --with-http_iconv_module --with-http_v2_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_secure_link_module --with-http_stub_status_module --with-http_addition_module
&& make && make install

:PS:
或可以直接的#./configure&& make && make install

第6步:测试服务器的启动

(1)创建一个工作目录

mkdir /data/www
cd /data/www
当前文件夹下创建两个目录
mkdir logs/ conf/

(2)我们在 conf 目录下创建一个nginx.conf 文件

worker_processes  1;
error_log logs/error.log;
events {
    worker_connections 1024;
}
http {
    server {
        listen 9000;
        location / {
            default_type text/html;
            content_by_lua '
                ngx.say("<p>Hello, World!</p>")
            ';
        }
    }
}

(3)启动服务,指定运行的配置文件和运行目录

cd /data/www
/usr/local/openresty/nginx/sbin/nginx -p `pwd`/ -c conf/nginx.conf

如果没有任何输出,说明启动成功,-p 指定我们的项目目录,-c 指定配置文件。

(4)测试查看结果

curl http://localhost:9000/

输出结果为。说明我们的已经安装成功!

<p>Hello, World!</p>

上一篇下一篇

猜你喜欢

热点阅读