centos 安装OpenResty,


一、安装准备

安装OpenResty之前,您必须将这些库 perl 5.6.1+, libreadline, libpcre, libssl安装在您的电脑之中。

安装perl支持

yum install perl* (yum安装perl相关支持)
yum install cpan (perl需要的程序库,需要cpan的支持)

安装其他

yum install readline-devel pcre-devel openssl-devel gcc

二、构建 OpenResty

下载

从下载页 Download下载最新的 OpenResty® 源码包,并且像下面的示例一样将其解压:
tar -xzvf openresty-VERSION.tar.gz

VERSION 的地方替换成您下载的源码包的版本号,比如说 1.11.2.2。

然后在进入 openresty-VERSION/ 目录, 然后输入以下命令配置:

./configure

默认, --prefix=/usr/local/openresty 程序会被安装到/usr/local/openresty目录。

您可以指定各种选项,比如

./configure --prefix=/opt/openresty \ 
    --with-luajit \ 
    --without-http_redis2_module \ 
    --with-http_iconv_module \ 
    --with-http_postgres_module

试着使用 ./configure --help 查看更多的选项。

配置文件(./configure script)运行出错可以到 build/nginx-VERSION/objs/autoconf.err 找到。 VERSION 必须与OpenResty版本号相对应, 比如 1.11.2.2。

make

您可以使用下面的命令来编译:
make

如果您的电脑支持多核 make 工作的特性, 您可以这样编译:
make -j2

make install

如果前面的步骤都没有问题的话,您可以使用下面的命令安装l OpenResty到您的系统之中:
make install

在 Linux,通常包括 sudo来执行root权限做的事情。

三、运行

[root@localhost openresty]# cd /usr/local/openresty/nginx
[root@localhost nginx]# sbin/nginx

四、确认是否运行成功

执行下面命令

[root@localhost nginx]# curl http://localhost

输出如下内容,说明已经成功运行

<!DOCTYPE html>
<html>
<head>
<title>Welcome to OpenResty!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to OpenResty!</h1>
<p>If you see this page, the OpenResty web platform is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="https://openresty.org/">openresty.org</a>.<br/>

<p><em>Thank you for flying OpenResty.</em></p>
</body>
</html>

或者在浏览器中输入http://localhost

相关内容

    暂无相关文章