openresty
- 安装openresty
1、源码安装
安装前准备:
yum install pcre-devel openssl-devel gcc curl
源码下载地址:openresty
解压、安装
tar -xzvf openresty-VERSION.tar.gz
cd openresty-VERSION/
./configure
make
sudo make install
2、仓库安装
sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
sudo yum install openresty
- helloworld
1/创建工程目录
mkdir ~/work
cd ~/work
mkdir logs/ conf/
2/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>")
';
}
}
}
3/启动nginx服务器
(1)配置环境变量
export PATH=/usr/local/openresty/nginx/sbin:$PATH
echo $PATH
(2) 启动nginx
nginx -p `pwd`/ -c conf/nginx.conf
(3) 测试服务器是否启动成功
* 查看端口
netstat -nultp|grep nginx
* curl命令
curl http://localhost:8080
(4) 查看结果
<p>hello, world</p>
网友评论