openresty搭建

准备一台虚拟机(此处用vagrant)

vagrant init envimation/ubuntu-xenial

修改Vagrantfile
配置网络模式和Ip
config.vm.network "public_network", ip:"192.168.1.130"


vagrant ssh

安装openresty

sudo apt-get update
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"
sudo apt-get update
sudo apt-get install openresty
sudo apt-get install curl
export 'export PATH=/usr/local/openresty/bin:$PATH'>> ~/.bashrc
source ~/.bashrc
mkdir ~/work
cd ~/work
mkdir logs/ conf/

准备配置

conf/nginx.conf中写入配置

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("

hello, world

") '; } } }

运行nginx,执行

nginx -p `pwd`/ -c conf/nginx.conf

验证

执行

curl http://localhost:8080/

得到

hello, world

你可能感兴趣的:(openresty搭建)