OpenResty入門(一) -- 簡介與安裝

1.官網地址

2.簡介

OpenResty(又稱:ngx_openresty) 是一個基於 NGINX 的可伸縮的 Web 平臺,由中國人章亦春發起,提供了很多高質量的第三方模塊。

OpenResty 是一個強大的 Web 應用服務器,Web 開發人員可以使用 Lua 腳本語言調動 Nginx 支持的各種 C 以及 Lua 模塊,更主要的是在性能方面,OpenResty可以 快速構造出足以勝任 10K 以上併發連接響應的超高性能 Web 應用系統。

360,UPYUN,阿里雲,新浪,騰訊網,去哪兒網,酷狗音樂等都是 OpenResty 的深度用戶

3.安裝

這裏注意,直接通過yum install openresty是無法安裝openresty的,需要進行其他yum操作,如下

--可能已經存在,但防止不存在還是需要下載一下
yum install yum-utils

--淘寶的openresty鏡像地址
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

然後執行yum install openresty
注意:如何查看openresty有無安裝成功,直接在查看usr/local文件夾下面是否存在openresty文件夾就行了,如果存在,就說明安裝成功了。

4.OpenResty中的Nginx

1.Nginx的安裝位置

默認在安裝好OpenResty後,Nginx在usr/local/openresty文件夾下,運行ls後會看到有Nginx目錄,這就表示OpenResty會默認安裝Nginx,查看usr/local/openresty/nginx/conf/nginx.conf會發現已經默認配置好了。

 server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

這裏就不在贅述Nginx的配置,有興趣可以查看其他博主的Nginx配置博客

2.啓動Nginx

在不同目錄下啓動的命令不同,在/下,命令爲usr/local/openresty/nginx/sbin -p 'pwd'/ -c conf/nginx.conf,其他目錄只需要注意sbin下的nginx.conf文件的絕對路徑即可,啓動後訪問你的主機ip,出現以下頁面說明openResty啓動成功。
訪問主角IP

發佈了17 篇原創文章 · 獲贊 0 · 訪問量 417
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章