openresty随笔2---helloworld

1.安装OpenResty:

下面是说明:

https://openresty.org/cn/linux-packages.html

ubuntu系统可以按照链接里面的教程安装openresty,如果是类ubuntu的系统可能会出一些问题,可以通过源码安装:

下载源码包:

wget https://openresty.org/download/openresty-1.13.6.2.tar.gz

我把文件放到/usr/local/src下,并解压

sudo tar -zxvf  openresty-1.13.6.2.tar.gz

安装需要准备相应的依,因为我的是deepin,用的源是ubuntu的,所有我看的是ubuntu的部分的说明:

apt-get install libpcre3-dev  libssl-dev perl make build-essential curl

进入安装目录

cd /usr/local/src/openresty-1.13.6.2

可以通过./configure --help查看各种模块,因为刚开始做,所以我一切都是默认

./configure

如果报错说明有些依赖没有安装,需要手动安装一下。

没有报错的话进行编译安装

make 
make install

完成以后发现,/usr/local/下多了一个openresty目录。

2.使用openresty:

因为我本地存在一个nginx,安装openresty后需要注意两个nginx.conf的端口不能重复。

修改nginx.conf配置将默认80端口改为,6001端口:

cd /usr/local/openresty/nginx/conf
vim nginx.conf

只是修改server下的端口好其他不变。

重启nginx

cd /usr/local/openresty/nginx/sbin
./nginx -c /usr/local/openresty/nginx/conf/nginx.conf
./nginx -s reload

 

出现:


 

Welcome to OpenResty!

If you see this page, the OpenResty web platform is successfully installed and working. Further configuration is required.

For online documentation and support please refer to openresty.org.
Commercial support is available at openresty.com.

Thank you for flying OpenResty.


 

3.helloworld的实现:

建议开发的时候将openresty目录发到vscode里面开发,修改目录所属权限

修改nginx.conf文件:

 location / {
            root   html;
            index  index.html index.htm;
        }

#下面是新增的
location /hello {
            default_type text/html;
            content_by_lua_block {
                ngx.say("<p>hello, world</p>")
            }
        }

当服务器请求的路径为/hello的时候会导引hello,world

 

conent_by_lua_block:是一个指令,可以通过下面的链接查看:

https://github.com/openresty/lua-nginx-module#directives

 

转载于:https://www.cnblogs.com/callmelx/p/11123730.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值