使用openresty搭建一个hello word(1),openrestyhello
使用openresty搭建一个hello word(1),openrestyhello
1打开官网点击接打开链,选择中文站
2官网第一个栏目是下载,这里根据自己的实际情况去选择,对于一些常见的 Linux 发行版本,OpenResty 提供 官方预编译包。确保你首先用这种方式来安装。我的是Centos7
所以我参考官网推荐的预编译包来安装的
3打开预编译包的地址http://openresty.org/cn/linux-packages.html
1)你只用创建一个名为 /etc/yum.repos.d/OpenResty.repo 的文件,包含下面的内容
[openresty]
name=Official OpenResty Repository
baseurl=https://copr-be.cloud.fedoraproject.org/results/openresty/openresty/epel-$releasever-$basearch/
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/openresty/openresty/pubkey.gpg
enabled=1
enabled_metadata=1
2)列出 openresty 资源库里面所有的包:
sudo yum --disablerepo="*" --enablerepo="openresty" list available
3)然后你可以安装一个包,比如安装 openresty, 像这样:sudo yum install openresty
上面的步骤就安装完了,如果是别的Linux发行版本,参考官网的说明,官网很详细4)先创建一个工作目录
mkdir ~/work
cd ~/work
mkdir logs/ conf
5)创建一个简单的纯文本文件名为conf / nginx。会有以下内容:worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}
6)配置nginx的环境变量vi /etc/profilePATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH
保存之后,运行如下命令使配置生效:source /etc/profile7)启动
nginx -p `pwd`/ -c conf/nginx.conf
8)浏览器输入 http://localhost:8080/ 看结果是否出现了hello, world!
评论暂时关闭